pub struct _WSI { /* private fields */ }Expand description
Platform-specific (WASM/browser) WebSocket interface backing the
WebSocket client; owns the underlying socket,
connection settings, channels and reconnection state.
Implementations§
Source§impl WebSocketInterface
impl WebSocketInterface
Sourcepub fn new(
url: Option<&str>,
config: Option<WebSocketConfig>,
sender_channel: Channel<(Message, Ack)>,
receiver_channel: Channel<Message>,
) -> Result<WebSocketInterface>
pub fn new( url: Option<&str>, config: Option<WebSocketConfig>, sender_channel: Channel<(Message, Ack)>, receiver_channel: Channel<Message>, ) -> Result<WebSocketInterface>
Create a new interface for the optional default URL and configuration, wired to the given sender and receiver channels.
Sourcepub fn default_url(self: &Arc<Self>) -> Option<String>
pub fn default_url(self: &Arc<Self>) -> Option<String>
Return the configured default URL used when no per-connect URL is given.
Sourcepub fn current_url(self: &Arc<Self>) -> Option<String>
pub fn current_url(self: &Arc<Self>) -> Option<String>
Return the URL of the current (or most recent) connection.
Sourcepub fn set_default_url(self: &Arc<Self>, url: &str)
pub fn set_default_url(self: &Arc<Self>, url: &str)
Set the default URL used for subsequent connection attempts.
Sourcepub fn set_current_url(self: &Arc<Self>, url: &str)
pub fn set_current_url(self: &Arc<Self>, url: &str)
Record the URL of the connection currently being established.
Sourcepub fn is_connected(self: &Arc<Self>) -> bool
pub fn is_connected(self: &Arc<Self>) -> bool
Return true if the socket is currently connected.
Sourcepub fn configure(&self, config: WebSocketConfig)
pub fn configure(&self, config: WebSocketConfig)
Replace the configuration applied to the next connection attempt.
Sourcepub async fn connect(
self: &Arc<Self>,
options: ConnectOptions,
) -> ConnectResult<Error>
pub async fn connect( self: &Arc<Self>, options: ConnectOptions, ) -> ConnectResult<Error>
Initiate the connection and start the background connect/reconnect task.
Depending on options.block_async_connect, either blocks until connected
or returns a receiver that fires once the connection is established.
Sourcepub fn try_send(self: &Arc<Self>, message: &Message) -> Result<()>
pub fn try_send(self: &Arc<Self>, message: &Message) -> Result<()>
Attempt to send a message directly over the underlying socket without blocking, returning an error if the socket is not currently available.
Sourcepub async fn close(self: &Arc<Self>) -> Result<()>
pub async fn close(self: &Arc<Self>) -> Result<()>
Close the current connection, releasing its resources and emitting a
Close event if it was connected; reconnection (if enabled) may follow.
Sourcepub async fn disconnect(self: &Arc<Self>) -> Result<()>
pub async fn disconnect(self: &Arc<Self>) -> Result<()>
Disable reconnection and close the connection, fully disconnecting.
Sourcepub fn trigger_abort(self: &Arc<Self>) -> Result<()>
pub fn trigger_abort(self: &Arc<Self>) -> Result<()>
Force-close the underlying socket while connected to simulate a dropped connection; intended for testing reconnection logic.
Trait Implementations§
Source§impl Drop for WebSocketInterface
impl Drop for WebSocketInterface
Auto Trait Implementations§
impl !Freeze for WebSocketInterface
impl !Unpin for WebSocketInterface
impl !UnsafeUnpin for WebSocketInterface
impl RefUnwindSafe for WebSocketInterface
impl Send for WebSocketInterface
impl Sync for WebSocketInterface
impl UnwindSafe for WebSocketInterface
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.