pub struct WscallServer { /* private fields */ }Expand description
Main server type used to register routes, filters, and event handlers.
Implementations§
Source§impl WscallServer
impl WscallServer
pub fn new() -> Self
pub fn with_chacha20_key(self, key: [u8; 32]) -> Self
pub fn with_aes256_key(self, key: [u8; 32]) -> Self
Sourcepub fn with_max_connections(self, max: usize) -> Self
pub fn with_max_connections(self, max: usize) -> Self
Caps the number of concurrently accepted connections.
When the cap is reached, new accept calls block until an existing
connection drops, providing natural backpressure against connection
flooding instead of spawning unbounded tasks.
Sourcepub fn with_max_in_flight(self, max: usize) -> Self
pub fn with_max_in_flight(self, max: usize) -> Self
Caps the number of concurrently in-flight request/event handlers per single connection, bounding per-connection CPU and memory usage.
pub fn handle(&self) -> ServerHandle
pub fn route<F, Fut>(&mut self, route: impl Into<String>, handler: F)
pub fn typed_route<T, F, Fut>(&mut self, route: impl Into<String>, handler: F)
pub fn validated_route<T, F, Fut>( &mut self, route: impl Into<String>, handler: F, )
pub fn filter<F, Fut>(&mut self, filter: F)where
F: Fn(ApiContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ApiContext, ApiError>> + Send + 'static,
pub fn event_handler<F, Fut>(&mut self, name: impl Into<String>, handler: F)
pub fn on_connected<F, Fut>(&mut self, handler: F)
pub fn on_disconnected<F, Fut>(&mut self, handler: F)
pub fn exception_handler<F, Fut>(&mut self, handler: F)where
F: Fn(ExceptionContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ErrorPayload> + Send + 'static,
pub async fn listen(self, address: &str) -> Result<(), ServerError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WscallServer
impl !UnwindSafe for WscallServer
impl Freeze for WscallServer
impl Send for WscallServer
impl Sync for WscallServer
impl Unpin for WscallServer
impl UnsafeUnpin for WscallServer
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