Skip to main content

WscallServer

Struct WscallServer 

Source
pub struct WscallServer { /* private fields */ }
Expand description

Main server type used to register routes, filters, and event handlers.

Implementations§

Source§

impl WscallServer

Source

pub fn new() -> Self

Source

pub fn with_chacha20_key(self, key: [u8; 32]) -> Self

Source

pub fn with_aes256_key(self, key: [u8; 32]) -> Self

Source

pub fn handle(&self) -> ServerHandle

Source

pub fn route<F, Fut>(&mut self, route: impl Into<String>, handler: F)
where F: Fn(ApiContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, ApiError>> + Send + 'static,

Source

pub fn typed_route<T, F, Fut>(&mut self, route: impl Into<String>, handler: F)
where T: DeserializeOwned + Send + 'static, F: Fn(ApiContext, T) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, ApiError>> + Send + 'static,

Source

pub fn validated_route<T, F, Fut>( &mut self, route: impl Into<String>, handler: F, )
where T: DeserializeOwned + Validate + Send + 'static, F: Fn(ApiContext, T) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, ApiError>> + Send + 'static,

Source

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,

Source

pub fn event_handler<F, Fut>(&mut self, name: impl Into<String>, handler: F)
where F: Fn(EventContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, ApiError>> + Send + 'static,

Source

pub fn on_connected<F, Fut>(&mut self, handler: F)
where F: Fn(ServerConnectionContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,

Source

pub fn on_disconnected<F, Fut>(&mut self, handler: F)
where F: Fn(ServerDisconnectContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,

Source

pub fn exception_handler<F, Fut>(&mut self, handler: F)
where F: Fn(ExceptionContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = ErrorPayload> + Send + 'static,

Source

pub async fn listen(self, address: &str) -> Result<(), ServerError>

Trait Implementations§

Source§

impl Default for WscallServer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V