pub struct SocketIoBuilder<A: Adapter = LocalAdapter> { /* private fields */ }
Expand description

A builder to create a SocketIo instance. It contains everything to configure the socket.io server with a SocketIoConfig. It can be used to build either a Tower Layer or a Service.

Implementations§

source§

impl<A: Adapter> SocketIoBuilder<A>

source

pub fn new() -> Self

Creates a new SocketIoBuilder with default config

source

pub fn req_path(self, req_path: impl Into<Cow<'static, str>>) -> Self

The path to listen for socket.io requests on.

Defaults to “/socket.io”.

source

pub fn ping_interval(self, ping_interval: Duration) -> Self

The interval at which the server will send a ping packet to the client.

Defaults to 25 seconds.

source

pub fn ping_timeout(self, ping_timeout: Duration) -> Self

The amount of time the server will wait for a ping response from the client before closing the connection.

Defaults to 20 seconds.

source

pub fn max_buffer_size(self, max_buffer_size: usize) -> Self

The maximum number of packets that can be buffered per connection before being emitted to the client. If the buffer if full the emit() method will return an error

Defaults to 128 packets.

source

pub fn max_payload(self, max_payload: u64) -> Self

The maximum size of a payload in bytes. If a payload is bigger than this value the emit() method will return an error.

Defaults to 100 kb.

source

pub fn transports<const N: usize>(self, transports: [TransportType; N]) -> Self

Allowed transports on this server

The transports array should have a size of 1 or 2

Defaults to : [TransportType::Polling, TransportType::Websocket]

source

pub fn ack_timeout(self, ack_timeout: Duration) -> Self

The amount of time the server will wait for an acknowledgement from the client before closing the connection.

Defaults to 5 seconds.

source

pub fn connect_timeout(self, connect_timeout: Duration) -> Self

The amount of time before disconnecting a client that has not successfully joined a namespace.

Defaults to 45 seconds.

source

pub fn with_config(self, config: SocketIoConfig) -> Self

Sets a custom SocketIoConfig created previously for this SocketIoBuilder

source

pub fn with_adapter<B: Adapter>(self) -> SocketIoBuilder<B>

Sets a custom Adapter for this SocketIoBuilder

source

pub fn with_state<S: Send + Sync + 'static>(self, state: S) -> Self

Available on crate feature state only.

Add a custom global state for the SocketIo instance. This state will be accessible from every handler with the State extractor. You can set any number of states as long as they have different types.

source

pub fn build_layer(self) -> (SocketIoLayer<A>, SocketIo<A>)

Builds a SocketIoLayer and a SocketIo instance

The layer can be used as a tower layer

source

pub fn build_svc(self) -> (SocketIoService<NotFoundService>, SocketIo)

Builds a SocketIoService and a SocketIo instance

This service will be a standalone service that return a 404 error for every non-socket.io request It can be used as a hyper service

source

pub fn build_with_inner_svc<S: Clone>( self, svc: S ) -> (SocketIoService<S>, SocketIo)

Builds a SocketIoService and a SocketIo instance with an inner service

It can be used as a hyper service

Trait Implementations§

source§

impl Default for SocketIoBuilder

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<A> RefUnwindSafe for SocketIoBuilder<A>
where A: RefUnwindSafe,

§

impl<A> Send for SocketIoBuilder<A>

§

impl<A> Sync for SocketIoBuilder<A>

§

impl<A> Unpin for SocketIoBuilder<A>
where A: Unpin,

§

impl<A> UnwindSafe for SocketIoBuilder<A>
where A: 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more