pub struct Multiserver<P, T: Transport = <P as HasTransport>::Transport> { /* private fields */ }Expand description
A server that handles incoming messages from multiple transports.
Multiservers are useful when you want to use a single server handler to handle messages from multiple served transports. They coalesce all of the incoming requests into a single conceptual stream, and invoke the handler on each one serially.
Multiserver is a handle that can forward server ends to its
MultiserverDispatcher. The dispatcher is what handles each of the
incoming messages. Call multiserver to create a handle and dispatcher
pair.
§Example
ⓘ
let (server, dispatcher) = multiserver();
spawn(dispatcher.run(my_handler));
while let Some(server_end) = incoming.next().await {
server.forward(server_end);
}Implementations§
Source§impl<P, T: Transport> Multiserver<P, T>
impl<P, T: Transport> Multiserver<P, T>
Trait Implementations§
Auto Trait Implementations§
impl<P, T> Freeze for Multiserver<P, T>
impl<P, T = <P as HasTransport>::Transport> !RefUnwindSafe for Multiserver<P, T>
impl<P, T> Send for Multiserver<P, T>
impl<P, T> Sync for Multiserver<P, T>
impl<P, T> Unpin for Multiserver<P, T>where
P: Unpin,
impl<P, T> UnsafeUnpin for Multiserver<P, T>
impl<P, T = <P as HasTransport>::Transport> !UnwindSafe for Multiserver<P, T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
Source§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
Converts the given service transport handle of type
T to Self