pub struct EventSink { /* private fields */ }Expand description
A list the core pushes events into while it handles a frame or a timeout.
A core receives &mut EventSink in BrokerCore::on_frame and
BrokerCore::on_timeout. The caller reads and empties it
afterwards. Events keep the order in which they were pushed.
§Examples
use brokapi_core::{Event, SubscriptionId};
use brokapi_sansio::EventSink;
let mut sink = EventSink::new();
assert!(sink.is_empty());
sink.push_payload(Some(SubscriptionId::new(1)), Event::Balances(vec![]));
assert_eq!(sink.len(), 1);
assert_eq!(sink.events()[0].sub, Some(SubscriptionId::new(1)));
// Draining hands the events over and leaves the sink empty.
let events = sink.drain();
assert_eq!(events.len(), 1);
assert!(sink.is_empty());Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventSink
impl RefUnwindSafe for EventSink
impl Send for EventSink
impl Sync for EventSink
impl Unpin for EventSink
impl UnsafeUnpin for EventSink
impl UnwindSafe for EventSink
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