Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

One connection to one network’s websocket.

Implementations§

Source§

impl Session

Source

pub fn tick(&mut self, now: u64) -> Tick

What the socket needs at now: a ping after Timing::ping_after_ms with no pong or data (once, until one arrives or as long again passes), or a reconnect after Timing::silent_ms of nothing at all.

Source

pub fn due(&self) -> Option<u64>

When a tick next has something to do; None while closed.

Source

pub fn closed(&mut self, now: u64, random: u64) -> Retry

The socket closed at now, or a connect failed. Gives how long to wait before the next connect, and the posts left unanswered. The wait doubles from Timing::first_retry_ms to Timing::last_retry_ms and random adds up to a quarter more, so many clients dropped at once do not return at once. It starts over after a socket that held (Timing::steady_ms). There is no last attempt.

Source§

impl Session

Source

pub fn new(network: Network) -> Self

A closed session on network, with the venue’s limits and the default timing.

Source

pub const fn with_limits(self, limits: Limits) -> Self

The limits are per IP: sessions sharing one split them.

Source

pub const fn with_timing(self, timing: Timing) -> Self

Source

pub const fn network(&self) -> Network

Source

pub const fn url(&self) -> &'static str

Where to connect: the network’s public websocket.

Source

pub const fn is_open(&self) -> bool

Source

pub fn wanted(&self) -> &[Subscription]

What this session subscribes to on every socket, in the order it was asked for.

Source

pub fn users(&self) -> usize

The distinct users the wanted subscriptions follow.

Source

pub fn waiting(&self) -> &[u64]

The ids of posts sent on this socket and not yet answered.

Source

pub fn subscribe( &mut self, subscription: Subscription, ) -> Result<Option<String>, Refused>

Wants subscription from now on, on this socket and every later one. Gives the frame to send when the socket is open and it is new; nothing when it was already wanted. Past the limits, or when the venue would not take it, it is refused and not kept.

Source

pub fn unsubscribe(&mut self, subscription: &Subscription) -> Option<String>

Stops wanting subscription. Gives the frame to send when the socket is open and it was wanted.

Source

pub fn post(&mut self, request: &Post) -> Result<(u64, String), Refused>

Gives the next post’s id and its frame. Only on an open socket, and only while fewer than the limit are waiting for an answer.

Source

pub fn opened(&mut self, now: u64) -> Vec<String>

The socket opened at now. Gives the frames that subscribe to everything wanted, in order.

Source

pub fn received(&mut self, now: u64, text: &str) -> Result<Frame, BadFrame>

A text frame arrived at now. Anything that arrives shows the socket is alive, whether it reads or not; only a pong or a subscription’s data puts off the next ping. A post’s answer or refusal stops it waiting.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more