pub struct Listener<CM, SM>where
CM: Send + Sync + 'static,
SM: Send + Sync + 'static,{ /* private fields */ }Expand description
Binds to a configured port and accepts incoming connections.
Implementations§
source§impl<CM, SM> Listener<CM, SM>where
CM: Send + Sync + 'static,
SM: Send + Sync + 'static,
impl<CM, SM> Listener<CM, SM>where CM: Send + Sync + 'static, SM: Send + Sync + 'static,
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>where
CM: Send + Sync + 'static,
SM: Send + Sync + 'static,
impl<CM, SM> Cancellable for Listener<CM, SM>where CM: Send + Sync + 'static, SM: Send + Sync + 'static,
§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.
§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, Global>>where
Self: Sized + Send + 'static + 'async_trait,
fn spawn<'async_trait>( self, cancellation_token: CancellationToken ) -> Pin<Box<dyn Future<Output = CancellableHandle<Self>> + Send + 'async_trait, Global>>where Self: Sized + Send + 'static + '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, Global>>where
Self: Sized + Send + 'static + 'async_trait,
F: FnMut(Self::Result) -> Result<(), Self::Result> + Send + 'static + '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, Global>>where Self: Sized + Send + 'static + 'async_trait, F: FnMut(Self::Result) -> Result<(), Self::Result> + Send + 'static + 'async_trait,
Consumes the service and spawns its work loop. Read more
Auto Trait Implementations§
impl<CM, SM> !RefUnwindSafe for Listener<CM, SM>
impl<CM, SM> Send for Listener<CM, SM>
impl<CM, SM> Sync for Listener<CM, SM>
impl<CM, SM> Unpin for Listener<CM, SM>where CM: Unpin, SM: Unpin,
impl<CM, SM> !UnwindSafe for Listener<CM, SM>
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