Struct trillium_websockets::JsonHandler
source · pub struct JsonHandler<T> { /* private fields */ }
Expand description
A wrapper type for JsonWebSocketHandler
s
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>
impl<T> Debug for JsonHandler<T>
source§impl<T> Deref for JsonHandler<T>
impl<T> Deref for JsonHandler<T>
source§impl<T> DerefMut for JsonHandler<T>
impl<T> DerefMut for JsonHandler<T>
source§impl<T> WebSocketHandler for JsonHandler<T>where
T: JsonWebSocketHandler,
impl<T> WebSocketHandler for JsonHandler<T>where
T: JsonWebSocketHandler,
§type OutboundStream = SerializedStream<<T as JsonWebSocketHandler>::StreamType>
type OutboundStream = SerializedStream<<T as JsonWebSocketHandler>::StreamType>
A
Stream
type that represents Message
s 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,
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,
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,
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,
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> Freeze for JsonHandler<T>where
T: Freeze,
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> 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
Mutably borrows from an owned value. Read more