pub struct NativeSocket { /* private fields */ }Expand description
Send + Sync handle for a managed client running on a dedicated thread.
Implementations§
Source§impl NativeSocket
impl NativeSocket
Sourcepub fn spawn(
endpoint: impl Into<String>,
config: ConnectionConfig,
) -> Result<Self, NativeRuntimeError>
pub fn spawn( endpoint: impl Into<String>, config: ConnectionConfig, ) -> Result<Self, NativeRuntimeError>
Starts a worker with static connection configuration and default options.
Sourcepub fn spawn_with_options(
endpoint: impl Into<String>,
config: ConnectionConfig,
options: NativeOptions,
) -> Result<Self, NativeRuntimeError>
pub fn spawn_with_options( endpoint: impl Into<String>, config: ConnectionConfig, options: NativeOptions, ) -> Result<Self, NativeRuntimeError>
Starts a worker with static connection configuration and custom options.
Sourcepub fn spawn_with_loader(
endpoint: impl Into<String>,
config_loader: NativeConnectionConfigLoader,
options: NativeOptions,
) -> Result<Self, NativeRuntimeError>
pub fn spawn_with_loader( endpoint: impl Into<String>, config_loader: NativeConnectionConfigLoader, options: NativeOptions, ) -> Result<Self, NativeRuntimeError>
Starts a worker with per-attempt connection configuration.
Sourcepub fn status(&self) -> SocketStatus
pub fn status(&self) -> SocketStatus
Returns the latest managed socket status.
Sourcepub fn events(&self) -> NativeSocketEvents
pub fn events(&self) -> NativeSocketEvents
Creates an independent bounded socket event receiver.
Sourcepub fn status_changes(&self) -> NativeSocketStatusChanges
pub fn status_changes(&self) -> NativeSocketStatusChanges
Creates a receiver for subsequent socket status changes.
Sourcepub fn worker_status(&self) -> NativeWorkerStatus
pub fn worker_status(&self) -> NativeWorkerStatus
Returns the latest worker-thread status.
Sourcepub fn worker_status_changes(&self) -> NativeWorkerStatusChanges
pub fn worker_status_changes(&self) -> NativeWorkerStatusChanges
Creates a receiver for subsequent worker-thread status changes.
Sourcepub async fn connect(&self) -> Result<(), NativeRuntimeError>
pub async fn connect(&self) -> Result<(), NativeRuntimeError>
Enables connection attempts.
Sourcepub async fn ping(&self) -> Result<Duration, NativeRuntimeError>
pub async fn ping(&self) -> Result<Duration, NativeRuntimeError>
Sends a heartbeat with the configured call timeout and returns its RTT.
Sourcepub async fn ping_with_timeout(
&self,
timeout: Duration,
) -> Result<Duration, NativeRuntimeError>
pub async fn ping_with_timeout( &self, timeout: Duration, ) -> Result<Duration, NativeRuntimeError>
Sends a heartbeat with an explicit timeout and returns its RTT.
Sourcepub async fn disconnect(&self) -> Result<(), NativeRuntimeError>
pub async fn disconnect(&self) -> Result<(), NativeRuntimeError>
Disables automatic reconnection and closes the active transport.
Sourcepub async fn disconnect_with(
&self,
code: u16,
reason: impl Into<String>,
) -> Result<(), NativeRuntimeError>
pub async fn disconnect_with( &self, code: u16, reason: impl Into<String>, ) -> Result<(), NativeRuntimeError>
Disconnects with an explicit WebSocket close code and reason.
Sourcepub async fn channel(
&self,
topic: impl Into<String>,
payload: Value,
) -> Result<NativeChannel, NativeRuntimeError>
pub async fn channel( &self, topic: impl Into<String>, payload: Value, ) -> Result<NativeChannel, NativeRuntimeError>
Registers a channel with a static join payload.
Sourcepub async fn channel_with_loader(
&self,
topic: impl Into<String>,
payload_loader: NativeJoinPayloadLoader,
) -> Result<NativeChannel, NativeRuntimeError>
pub async fn channel_with_loader( &self, topic: impl Into<String>, payload_loader: NativeJoinPayloadLoader, ) -> Result<NativeChannel, NativeRuntimeError>
Registers a channel with a payload loader evaluated for every join.
Sourcepub async fn shutdown(&self) -> Result<(), NativeRuntimeError>
pub async fn shutdown(&self) -> Result<(), NativeRuntimeError>
Permanently stops and joins the dedicated worker.
Sourcepub fn join_worker(&self) -> Result<(), NativeRuntimeError>
pub fn join_worker(&self) -> Result<(), NativeRuntimeError>
Blocks the current thread until the worker exits.
Async callers should normally use NativeSocket::shutdown instead.
Trait Implementations§
Source§impl Clone for NativeSocket
impl Clone for NativeSocket
Source§fn clone(&self) -> NativeSocket
fn clone(&self) -> NativeSocket
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more