pub struct RouterBuilder { /* private fields */ }Expand description
Builder for creating a Router for accepting protocols.
Implementations§
Source§impl RouterBuilder
impl RouterBuilder
Sourcepub fn new(endpoint: Endpoint) -> RouterBuilder
pub fn new(endpoint: Endpoint) -> RouterBuilder
Creates a new router builder using given Endpoint.
Sourcepub fn incoming_filter(
self,
filter: Arc<dyn Fn(&Incoming) -> IncomingFilterOutcome + Sync + Send>,
) -> RouterBuilder
pub fn incoming_filter( self, filter: Arc<dyn Fn(&Incoming) -> IncomingFilterOutcome + Sync + Send>, ) -> RouterBuilder
Sets a filter that decides whether to accept an incoming connection before the TLS handshake completes.
The filter is called with the raw Incoming for each connection attempt
and returns an IncomingFilterOutcome that determines what happens next.
Implementers have full access to the Incoming and can use any of its
methods (including Incoming::decrypt) to make their decision. Note that
decrypt() is relatively expensive, so filters should reject based on
cheaper signals (e.g. remote address) first.
Sourcepub fn accept(
self,
alpn: impl AsRef<[u8]>,
handler: impl Into<Box<dyn DynProtocolHandler>>,
) -> RouterBuilder
pub fn accept( self, alpn: impl AsRef<[u8]>, handler: impl Into<Box<dyn DynProtocolHandler>>, ) -> RouterBuilder
Configures the router to accept the ProtocolHandler when receiving a connection
with this alpn.
handler can either be a type that implements ProtocolHandler or a
Box<dyn DynProtocolHandler>.