Skip to main content

Channel

Struct Channel 

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

One WebSocket connection. Every segment of the channel is multiplexed over it; another Channel, even for the same reference, is another connection (SEG-01). Obtain one with Client::channel.

A Channel is cheap to clone, and every clone is the same channel. Close it when done: dropping every handle also stops its connection, without the closing handshake.

Implementations§

Source§

impl Channel

Source

pub fn reference(&self) -> &str

The channel reference that this channel connects to.

Source

pub fn state(&self) -> ChannelState

The current state. It may change as soon as it is read.

Source

pub fn events(&self) -> ChannelEventHandler

The handler for channel-wide listeners.

Source

pub fn segment(&self, segment_id: &str) -> Result<Segment, CelerisError>

A handle for the segment with the given id. It does no network work, and any number of handles for one segment share its subscriptions and listeners. It fails with CelerisError::Configuration for an id that is empty or contains CR or LF.

Source

pub fn default_segment(&self) -> Segment

A handle for the segment that every connection joins automatically (SEG-01).

Source

pub async fn connect(&self) -> Result<(), CelerisError>

Opens the connection. It returns once the WebSocket is established and the held subscriptions are queued to be restored ahead of any publish, or fails without a retry: only a connection that was up recovers automatically.

It fails with CelerisError::OperationInProgress while connecting, connected or reconnecting, and with CelerisError::NotConnected once the channel is closing or closed. A failed attempt leaves the channel ChannelState::Failed, from which connect may be called again. Dropping the returned future abandons the attempt and leaves the channel failed.

Source

pub async fn close(&self)

Closes the connection and every segment handle with it. It is terminal and idempotent, and returns within about five seconds even when the server does not answer. Publishes and presence queries that still wait fail with CelerisError::Cancelled.

Trait Implementations§

Source§

impl Clone for Channel

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 Channel

Source§

fn fmt(&self, formatter: &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<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, 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> 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.