pub struct ServerHandshake<S, C> {
callback: Option<C>,
config: Option<WebSocketConfig>,
error_response: Option<ErrorResponse>,
_marker: PhantomData<S>,
}
Expand description
Server handshake role.
Fields§
§callback: Option<C>
Callback which is called whenever the server read the request from the client and is ready to reply to it. The callback returns an optional headers which will be added to the reply which the server sends to the user.
config: Option<WebSocketConfig>
WebSocket configuration.
error_response: Option<ErrorResponse>
Error code/flag. If set, an error will be returned after sending response to the client.
_marker: PhantomData<S>
Internal stream type.
Implementations§
source§impl<S: Read + Write, C: Callback> ServerHandshake<S, C>
impl<S: Read + Write, C: Callback> ServerHandshake<S, C>
sourcepub fn start(
stream: S,
callback: C,
config: Option<WebSocketConfig>,
) -> MidHandshake<Self>
pub fn start( stream: S, callback: C, config: Option<WebSocketConfig>, ) -> MidHandshake<Self>
Start server handshake. callback
specifies a custom callback which the user can pass to
the handshake, this callback will be called when the a websocket client connects to the
server, you can specify the callback if you want to add additional header to the client
upon join based on the incoming headers.
Trait Implementations§
impl<S: Read + Write, C: Callback> HandshakeRole for ServerHandshake<S, C>
Auto Trait Implementations§
impl<S, C> Freeze for ServerHandshake<S, C>where
C: Freeze,
impl<S, C> !RefUnwindSafe for ServerHandshake<S, C>
impl<S, C> Send for ServerHandshake<S, C>
impl<S, C> Sync for ServerHandshake<S, C>
impl<S, C> Unpin for ServerHandshake<S, C>
impl<S, C> !UnwindSafe for ServerHandshake<S, C>
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