pub struct OutputManagementHandler { /* private fields */ }
Implementations§
Source§impl OutputManagementHandler
impl OutputManagementHandler
Sourcepub fn new(event_tx: Sender<OutputManagementEvent>) -> Self
pub fn new(event_tx: Sender<OutputManagementEvent>) -> Self
Examples found in repository?
examples/output.rs (line 15)
7async fn main() {
8 // create mpsc channel for interacting with the output handler
9 let (output_msg_tx, mut output_msg_rx) = mpsc::channel(128);
10
11 // create mpsc channel for receiving events from the output handler
12 let (output_event_tx, mut output_event_rx) = mpsc::channel(128);
13
14 // create the handler instance
15 let mut output_handler = OutputManagementHandler::new(output_event_tx);
16
17
18 // start the output handler
19 let output_t = tokio::spawn(async move {
20 let _ = output_handler.run(output_msg_rx).await;
21 });
22
23 // receive all output events
24 let output_event_t = tokio::spawn(async move {
25 loop {
26 let msg = output_event_rx.recv().await;
27 if msg.is_none() {
28 continue;
29 }
30 println!("received output_event event={:?}", msg);
31 }
32 });
33
34 let _ = output_t.await.unwrap();
35 let _ = output_event_t.await.unwrap();
36}
Sourcepub async fn run(&mut self, msg_rx: Receiver<OutputManagementMessage>)
pub async fn run(&mut self, msg_rx: Receiver<OutputManagementMessage>)
Examples found in repository?
examples/output.rs (line 20)
7async fn main() {
8 // create mpsc channel for interacting with the output handler
9 let (output_msg_tx, mut output_msg_rx) = mpsc::channel(128);
10
11 // create mpsc channel for receiving events from the output handler
12 let (output_event_tx, mut output_event_rx) = mpsc::channel(128);
13
14 // create the handler instance
15 let mut output_handler = OutputManagementHandler::new(output_event_tx);
16
17
18 // start the output handler
19 let output_t = tokio::spawn(async move {
20 let _ = output_handler.run(output_msg_rx).await;
21 });
22
23 // receive all output events
24 let output_event_t = tokio::spawn(async move {
25 loop {
26 let msg = output_event_rx.recv().await;
27 if msg.is_none() {
28 continue;
29 }
30 println!("received output_event event={:?}", msg);
31 }
32 });
33
34 let _ = output_t.await.unwrap();
35 let _ = output_event_t.await.unwrap();
36}
Auto Trait Implementations§
impl Freeze for OutputManagementHandler
impl !RefUnwindSafe for OutputManagementHandler
impl Send for OutputManagementHandler
impl Sync for OutputManagementHandler
impl Unpin for OutputManagementHandler
impl !UnwindSafe for OutputManagementHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.