Listener

Struct Listener 

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

Source

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,

Source§

type Result = Client<Connection<WebSocketStream<TcpStream>>, CM, SM>

Type of values that can be yielded by the service.
Source§

type Handle = ()

Type of a handle for communicating with the service.
Source§

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,

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,

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

impl<CM, SM> Debug for Listener<CM, SM>
where CM: Send + Sync + 'static + Debug, SM: Send + Sync + 'static + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<CM, SM> !Freeze for Listener<CM, SM>

§

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>
where CM: UnwindSafe, SM: 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, 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

Source§

impl<T> ErasedDestructor for T
where T: 'static,