pub struct SocketServer { /* private fields */ }
Expand description

The handle to define, start and shutdown a Reactive Server for Socket Connections

Implementations§

source§

impl SocketServer

source

pub fn new(interface_ip: String, port: u16) -> Self

Creates a new server instance listening on TCP/IP: interface_ip: the interface’s IP to listen to – 0.0.0.0 will cause listening to all network interfaces port: what port to listen to processor_builder_fn: a function to instantiate a new processor Stream whenever a new connection arrives

source

pub async fn spawn_responsive_processor<RemotePeerMessages: SocketServerDeserializer<RemotePeerMessages> + Send + Sync + PartialEq + Debug + 'static, LocalPeerMessages: SocketServerSerializer<LocalPeerMessages> + Send + Sync + PartialEq + Debug + 'static, LocalStreamType: Stream<Item = LocalPeerMessages> + Send + 'static, ConnectionEventsCallbackFuture: Future<Output = ()> + Send, ConnectionEventsCallback: Fn(ConnectionEvent<LocalPeerMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static, ProcessorBuilderFn: Fn(String, u16, Arc<Peer<LocalPeerMessages>>, ProcessorRemoteStreamType<RemotePeerMessages>) -> LocalStreamType + Send + Sync + 'static>( &mut self, server_events_callback: ConnectionEventsCallback, dialog_processor_builder_fn: ProcessorBuilderFn ) -> Result<(), Box<dyn Error + Sync + Send + 'static>>

Spawns a task to run the Server listening @ self’s interface_ip & port and returns, immediately, an object through which the caller may inquire some stats (if opted in) and request the server to shutdown.
The given dialog_processor_builder_fn will be called for each new client and will return a reactive-mutiny Stream that will produce non-futures & non-fallibles ServerMessages that will be sent to the clients.

source

pub fn shutdown_waiter( &mut self ) -> impl FnOnce() -> BoxFuture<'static, Result<(), Box<dyn Error + Send + Sync>>>

Returns an async closure that blocks until [shutdown()] is called. Example:

    self.shutdown_waiter()().await;
source

pub fn shutdown(self) -> Result<(), Box<dyn Error>>

Trait Implementations§

source§

impl Debug for SocketServer

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.