pub struct SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: SocketService,{ /* private fields */ }Expand description
A SocketRpcServer is a server future. It listens on a socket and spawns new connections,
with a ConnectionService to handle each connection.
Protosockets use monomorphic messages: You can only have 1 kind of message per service.
The expected way to work with this is to use prost, messagepack, or some other format that
has a notion of a oneof, and list your message types in that.
The socket server hosts your SocketService. Your SocketService creates a ConnectionService for each new connection. Your ConnectionService manages one connection. It is Dropped when the connection is closed.
Implementations§
Source§impl<TSocketService> SocketRpcServer<TSocketService, TokioSpawn<Connection<<TSocketService::SocketListener as SocketListener>::Stream, TSocketService::Codec, RpcSubmitter<TSocketService::ConnectionService>>>>where
TSocketService: SocketService,
TSocketService::Codec: Send,
<TSocketService::Codec as Encoder>::Serialized: Send,
<TSocketService::SocketListener as SocketListener>::Stream: Send,
TSocketService::ConnectionService: Send,
impl<TSocketService> SocketRpcServer<TSocketService, TokioSpawn<Connection<<TSocketService::SocketListener as SocketListener>::Stream, TSocketService::Codec, RpcSubmitter<TSocketService::ConnectionService>>>>where
TSocketService: SocketService,
TSocketService::Codec: Send,
<TSocketService::Codec as Encoder>::Serialized: Send,
<TSocketService::SocketListener as SocketListener>::Stream: Send,
TSocketService::ConnectionService: Send,
Sourcepub fn new(
listener: TSocketService::SocketListener,
socket_server: TSocketService,
max_buffer_length: usize,
buffer_allocation_increment: usize,
max_queued_outbound_messages: usize,
) -> Result<Self>
pub fn new( listener: TSocketService::SocketListener, socket_server: TSocketService, max_buffer_length: usize, buffer_allocation_increment: usize, max_queued_outbound_messages: usize, ) -> Result<Self>
Construct a new SocketRpcServer with a listener.
This assumes a Tokio runtime, and is only available when your SocketService is
transitively Send.
Source§impl<TSocketService, TSpawnConnection> SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: SocketService,
TSpawnConnection: Spawn<Connection<<TSocketService::SocketListener as SocketListener>::Stream, TSocketService::Codec, RpcSubmitter<TSocketService::ConnectionService>>>,
impl<TSocketService, TSpawnConnection> SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: SocketService,
TSpawnConnection: Spawn<Connection<<TSocketService::SocketListener as SocketListener>::Stream, TSocketService::Codec, RpcSubmitter<TSocketService::ConnectionService>>>,
Sourcepub fn new_with_spawner(
listener: TSocketService::SocketListener,
socket_server: TSocketService,
max_buffer_length: usize,
buffer_allocation_increment: usize,
max_queued_outbound_messages: usize,
spawner: TSpawnConnection,
) -> Result<Self>
pub fn new_with_spawner( listener: TSocketService::SocketListener, socket_server: TSocketService, max_buffer_length: usize, buffer_allocation_increment: usize, max_queued_outbound_messages: usize, spawner: TSpawnConnection, ) -> Result<Self>
Construct a new SocketRpcServer with a listener and a spawner.
Sourcepub fn set_max_buffer_length(&mut self, max_buffer_length: usize)
pub fn set_max_buffer_length(&mut self, max_buffer_length: usize)
Set the maximum buffer length for connections created by this server after the setting is applied.
Sourcepub fn set_max_queued_outbound_messages(
&mut self,
max_queued_outbound_messages: usize,
)
pub fn set_max_queued_outbound_messages( &mut self, max_queued_outbound_messages: usize, )
Set the maximum queued outbound messages for connections created by this server after the setting is applied.
Trait Implementations§
Source§impl<TSocketService, TSpawnConnection> Future for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: SocketService,
TSpawnConnection: Spawn<Connection<<TSocketService::SocketListener as SocketListener>::Stream, TSocketService::Codec, RpcSubmitter<TSocketService::ConnectionService>>>,
impl<TSocketService, TSpawnConnection> Future for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: SocketService,
TSpawnConnection: Spawn<Connection<<TSocketService::SocketListener as SocketListener>::Stream, TSocketService::Codec, RpcSubmitter<TSocketService::ConnectionService>>>,
impl<TSocketService, TSpawnConnection> Unpin for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: SocketService,
Auto Trait Implementations§
impl<TSocketService, TSpawnConnection> Freeze for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: Freeze,
TSpawnConnection: Freeze,
<TSocketService as SocketService>::SocketListener: Freeze,
impl<TSocketService, TSpawnConnection> RefUnwindSafe for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: RefUnwindSafe,
TSpawnConnection: RefUnwindSafe,
<TSocketService as SocketService>::SocketListener: RefUnwindSafe,
impl<TSocketService, TSpawnConnection> Send for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: Send,
TSpawnConnection: Send,
<TSocketService as SocketService>::SocketListener: Send,
impl<TSocketService, TSpawnConnection> Sync for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: Sync,
TSpawnConnection: Sync,
<TSocketService as SocketService>::SocketListener: Sync,
impl<TSocketService, TSpawnConnection> UnsafeUnpin for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: UnsafeUnpin,
TSpawnConnection: UnsafeUnpin,
<TSocketService as SocketService>::SocketListener: UnsafeUnpin,
impl<TSocketService, TSpawnConnection> UnwindSafe for SocketRpcServer<TSocketService, TSpawnConnection>where
TSocketService: UnwindSafe,
TSpawnConnection: UnwindSafe,
<TSocketService as SocketService>::SocketListener: 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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f. Read moreSource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll will never again be called once it has
completed. This method can be used to turn any Future into a
FusedFuture. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
() on completion and sends
its output to another future on a separate task. Read moreSource§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = ()>.Source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = Never>.