Skip to main content

Socket

Struct Socket 

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

Handle used to configure channels and control the managed connection.

The companion Driver owns all protocol and transport state and must be polled continuously.

Implementations§

Source§

impl Socket

Source

pub fn new( connector: impl Connector + 'static, timer: impl Timer + 'static, options: Options, ) -> (Self, Driver)

Creates a socket and driver using the bounded default Phoenix v2 codec.

Source

pub fn new_with_codec( connector: impl Connector + 'static, timer: impl Timer + 'static, options: Options, codec: impl Codec + 'static, ) -> (Self, Driver)

Creates a socket and driver using an application-provided codec.

Source

pub fn channel( &self, topic: impl Into<String>, payload_loader: JoinPayloadLoader, ) -> Result<Channel, ClientError>

Registers one channel topic and its per-attempt join payload loader.

Only one live Channel handle may exist for a topic.

Source

pub fn events(&self) -> Result<SocketEvents, ClientError>

Creates an independent bounded socket event subscriber.

Source

pub fn status(&self) -> SocketStatus

Returns the latest socket status.

Source

pub fn status_changes(&self) -> SocketStatusChanges

Creates a stream of subsequent socket status changes.

Source

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

Enables connection attempts and waits until the command is accepted.

Source

pub async fn disconnect(&self) -> Result<(), ClientError>

Disables automatic reconnection and closes the active transport.

Source

pub async fn disconnect_with( &self, code: u16, reason: impl Into<String>, ) -> Result<(), ClientError>

Disconnects with an explicit WebSocket close code and reason.

Source

pub async fn reconnect(&self) -> Result<(), ClientError>

Disconnects and immediately enables a new connection cycle.

Source

pub async fn ping(&self) -> Result<Duration, ClientError>

Sends a heartbeat using the default call timeout and returns its RTT.

Source

pub async fn ping_with_timeout( &self, timeout: Duration, ) -> Result<Duration, ClientError>

Sends a heartbeat with an explicit timeout and returns its RTT.

Source

pub async fn shutdown(&self) -> Result<(), ClientError>

Permanently stops the driver and closes the active transport.

Trait Implementations§

Source§

impl Clone for Socket

Source§

fn clone(&self) -> Socket

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

Auto Trait Implementations§

§

impl Freeze for Socket

§

impl !RefUnwindSafe for Socket

§

impl !Send for Socket

§

impl !Sync for Socket

§

impl Unpin for Socket

§

impl UnsafeUnpin for Socket

§

impl !UnwindSafe for Socket

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.

§

impl<T> Instrument for T

§

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

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

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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