pub struct EventStream { /* private fields */ }Expand description
A live connection. Read it with EventStream::next_event; drop or
close it when finished.
Implementations§
Source§impl EventStream
impl EventStream
pub fn open(base_url: &str, token: &str, hooks: Hooks) -> Result<Self>
Sourcepub fn next_event(&self, timeout: Option<Duration>) -> Option<AccountEvent>
pub fn next_event(&self, timeout: Option<Duration>) -> Option<AccountEvent>
The next event, or None if the stream ends or timeout runs out.
Blocking forever is right for a long-lived listener and wrong for anything with a deadline: a stream that is healthy and silent would never return. Pass a timeout for the second case.
Sourcepub fn wait_until_open(&self, timeout: Duration) -> bool
pub fn wait_until_open(&self, timeout: Duration) -> bool
Blocks until the socket is up, or the stream ends, or time runs out.
Connecting is retried in the background forever, which is right for a long-lived listener and wrong for a caller with something else it could be doing: without this, a stream that never connects looks exactly like a stream with nothing to say.
Sourcepub fn closed_reason(&self) -> Option<(u16, String)>
pub fn closed_reason(&self) -> Option<(u16, String)>
Why it ended, once it has.
Trait Implementations§
Source§impl Drop for EventStream
impl Drop for EventStream
Auto Trait Implementations§
impl !Freeze for EventStream
impl Forget for EventStream
impl Move for EventStream
impl RefUnwindSafe for EventStreamwhere
Mutex<Receiver<Item>>: RefUnwindSafe,
Sender<Item>: RefUnwindSafe,
Atomic<usize>: RefUnwindSafe,
Atomic<bool>: RefUnwindSafe,
Mutex<bool>: RefUnwindSafe,
Condvar: RefUnwindSafe,
Mutex<Option<(u16, String)>>: RefUnwindSafe,
Mutex<Option<JoinHandle<()>>>: RefUnwindSafe,
impl Send for EventStream
impl Sync for EventStream
impl Unpin for EventStream
impl UnsafeUnpin for EventStreamwhere
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*mut Counter<Channel<Item>>: UnsafeUnpin,
*mut Counter<Channel<Item>>: UnsafeUnpin,
*mut Counter<Channel<Item>>: UnsafeUnpin,
*const ArcInner<Shared> is !null: UnsafeUnpin,
PhantomData<ArcInner<Shared>>: UnsafeUnpin,
*const ArcInner<Inner> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner>>: UnsafeUnpin,
*const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin,
impl UnwindSafe for EventStreamwhere
Mutex<Receiver<Item>>: UnwindSafe,
Sender<Item>: UnwindSafe,
Arc<Shared>: UnwindSafe,
Mutex<Option<JoinHandle<()>>>: UnwindSafe,
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