pub struct Listener<CM, SM>{ /* private fields */ }Expand description
Binds to a configured port and accepts incoming connections.
Implementations§
Source§impl<CM, SM> Listener<CM, SM>
impl<CM, SM> Listener<CM, SM>
Sourcepub async fn bind(
config: ListenerConfig,
cancellation_token: CancellationToken,
) -> Result<Self, ListenerError>
pub async fn bind( config: ListenerConfig, cancellation_token: CancellationToken, ) -> Result<Self, ListenerError>
Constructs the listener and binds it to the configured socket.
§Arguments
config- configuration for the listener and all its clients.cancellation_token- cancels the listener, unbinding it from the socket and sends a termination signal to all clients spawned from this listener.
§Returns
Ok(Self) if it successfully bound to the socket. See
ListenerError for errors descriptions.
Trait Implementations§
Source§impl<CM, SM> Cancellable for Listener<CM, SM>
impl<CM, SM> Cancellable for Listener<CM, SM>
Source§type Result = Client<Connection<WebSocketStream<TcpStream>>, CM, SM>
type Result = Client<Connection<WebSocketStream<TcpStream>>, CM, SM>
Type of values that can be yielded by the service.
Source§type Error = ListenerError
type Error = ListenerError
Error returned by
Self::run method.Source§fn new_handle<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Self::Handle> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn new_handle<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Self::Handle> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Constructs a new handle for communicating with the service. Read more
Source§fn run<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<CancellationResult<Self::Result>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<CancellationResult<Self::Result>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Performs a single unit of work. Read more
Source§fn spawn<'async_trait>(
self,
cancellation_token: CancellationToken,
) -> Pin<Box<dyn Future<Output = CancellableHandle<Self>> + Send + 'async_trait>>
fn spawn<'async_trait>( self, cancellation_token: CancellationToken, ) -> Pin<Box<dyn Future<Output = CancellableHandle<Self>> + Send + 'async_trait>>
Consumes the service and spawns its work loop. Read more
Source§fn spawn_with_callback<'async_trait, F>(
self,
cancellation_token: CancellationToken,
callback: F,
) -> Pin<Box<dyn Future<Output = CancellableHandle<Self>> + Send + 'async_trait>>
fn spawn_with_callback<'async_trait, F>( self, cancellation_token: CancellationToken, callback: F, ) -> Pin<Box<dyn Future<Output = CancellableHandle<Self>> + Send + 'async_trait>>
Consumes the service and spawns its work loop. Read more
Auto Trait Implementations§
impl<CM, SM> !Freeze for Listener<CM, SM>
impl<CM, SM> RefUnwindSafe for Listener<CM, SM>where
CM: RefUnwindSafe,
SM: RefUnwindSafe,
impl<CM, SM> Send for Listener<CM, SM>
impl<CM, SM> Sync for Listener<CM, SM>
impl<CM, SM> Unpin for Listener<CM, SM>
impl<CM, SM> UnwindSafe for Listener<CM, SM>where
CM: UnwindSafe,
SM: UnwindSafe,
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