Skip to main content

EventStream

Struct EventStream 

Source
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

Source

pub fn open(base_url: &str, token: &str, hooks: Hooks) -> Result<Self>

Source

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.

Source

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.

Source

pub fn ended(&self) -> bool

True once the stream has stopped for good and will not reconnect.

Source

pub fn closed_reason(&self) -> Option<(u16, String)>

Why it ended, once it has.

Source

pub fn close(&self)

Stops listening and closes the socket. Safe to call twice.

Trait Implementations§

Source§

impl Drop for EventStream

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for EventStream

§

impl Forget for EventStream

§

impl Move for EventStream

§

impl RefUnwindSafe for EventStream

§

impl Send for EventStream
where Mutex<Receiver<Item>>: Send, Sender<Item>: Send, Arc<Shared>: Send, Mutex<Option<JoinHandle<()>>>: Send,

§

impl Sync for EventStream
where Mutex<Receiver<Item>>: Sync, Sender<Item>: Sync, Arc<Shared>: Sync, Mutex<Option<JoinHandle<()>>>: Sync,

§

impl Unpin for EventStream
where Align4<u32>: Unpin, Align1<u8>: Unpin, *mut Counter<Channel<Item>>: Unpin, *mut Counter<Channel<Item>>: Unpin, *mut Counter<Channel<Item>>: Unpin, Arc<Shared>: Unpin, Arc<Inner, System>: Unpin, Arc<Packet<'static, ()>>: Unpin,

§

impl UnsafeUnpin for EventStream
where 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 EventStream

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V