pub struct JsonHandler<T> { /* private fields */ }
Expand description

A wrapper type for JsonWebSocketHandlers

You do not need to interact with this type directly. Instead, use WebSocket::new_json or json_websocket.

Trait Implementations§

source§

impl<T> Debug for JsonHandler<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T> Deref for JsonHandler<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> DerefMut for JsonHandler<T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<T> WebSocketHandler for JsonHandler<T>

§

type OutboundStream = SerializedStream<<T as JsonWebSocketHandler>::StreamType>

A [Stream] type that represents Messages to be sent to this client. It is built in your implementation code, in WebSocketHandler::connect. Use Pending<Message> or another stream that never returns if you do not need to use this aspect of the trait.
source§

fn connect<'life0, 'async_trait>( &'life0 self, conn: WebSocketConn ) -> Pin<Box<dyn Future<Output = Option<(WebSocketConn, Self::OutboundStream)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

This interface is the only mandatory function in WebSocketHandler. It receives an owned WebSocketConn and optionally returns it along with an OutboundStream type.
source§

fn inbound<'life0, 'life1, 'async_trait>( &'life0 self, message: Message, conn: &'life1 mut WebSocketConn ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

This interface function is called once with every message received from a connected websocket client.
source§

fn disconnect<'life0, 'life1, 'async_trait>( &'life0 self, conn: &'life1 mut WebSocketConn, close_frame: Option<CloseFrame<'static>> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

This interface function is called with the websocket conn and, in the case of a clean disconnect, the [CloseFrame] if one is sent available.
source§

fn send<'life0, 'life1, 'async_trait>( &'life0 self, message: Message, conn: &'life1 mut WebSocketConn ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

This interface function is called once with every outbound message in the OutboundStream. You likely do not need to implement this, but if you do, you must call conn.send(message).await or the message will not be sent.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for JsonHandler<T>
where T: RefUnwindSafe,

§

impl<T> Send for JsonHandler<T>
where T: Send,

§

impl<T> Sync for JsonHandler<T>
where T: Sync,

§

impl<T> Unpin for JsonHandler<T>
where T: Unpin,

§

impl<T> UnwindSafe for JsonHandler<T>
where T: UnwindSafe,

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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V