Skip to main content

Events

Trait Events 

Source
pub trait Events {
    type Next<'a>
       where Self: 'a;

    // Required method
    fn next_event(&mut self) -> Self::Next<'_>;
}
Expand description

Takes the next occurrence of a subscribed event: the next_event of a generated Client and blocking::Client.

Next is generic over the borrow of self, so one trait serves both clients: the async client’s Next<'a> is its event future, which borrows the client’s port, and the blocking client’s is the owned Result<Option<Event>, ReadError>. The trait gives the method a namespace of its own and nothing more: Next carries no bound, so code generic over Events cannot use what next_event returns.

use ridl_rt::face::Events;

struct Client { queue: Vec<u8> }
impl Events for Client {
    type Next<'a> = Option<u8> where Self: 'a;
    fn next_event(&mut self) -> Option<u8> { self.queue.pop() }
}

let mut client = Client { queue: vec![1] };
assert_eq!(client.next_event(), Some(1));
assert_eq!(client.next_event(), None);

Required Associated Types§

Source

type Next<'a> where Self: 'a

What one call of next_event returns: a future for the async client, an owned result for the blocking one.

Required Methods§

Source

fn next_event(&mut self) -> Self::Next<'_>

Takes the next occurrence of any subscribed event of the interface.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§