pub struct RpcServer<Context, T: Transport + ?Sized> { /* private fields */ }Expand description
RpcServer receives and process different requests from the RpcClient
Once a RpcServer is inited, you should attach a transport and handler for the port creation.
Implementations§
Source§impl<Context: Send + Sync + 'static, T: Transport + ?Sized + 'static> RpcServer<Context, T>
impl<Context: Send + Sync + 'static, T: Transport + ?Sized + 'static> RpcServer<Context, T>
pub fn create(ctx: Context) -> Self
Sourcepub fn get_server_events_sender(&self) -> ServerEventsSender<T>
pub fn get_server_events_sender(&self) -> ServerEventsSender<T>
Get a ServerEventsSender to send allowed server events from outside
Sourcepub async fn attach_transport(&mut self, transport: Arc<T>) -> ServerResult<()>
pub async fn attach_transport(&mut self, transport: Arc<T>) -> ServerResult<()>
Attaches the server half of the transport for Client<>Server communications
It differs from sending the ServerEvents::AtacchTransport because it can only be used to attach transport from the current thread where the RpcServer was initalized due to the mutably borrow
It receives the Transport inside an Arc because it must be sharable.
Sourcepub async fn run(&mut self)
pub async fn run(&mut self)
Start processing ServerEvent events and listening on a channel for new TransportNotification that are sent by all the attached transports that are running in background tasks.
Sourcepub fn set_module_registrator_handler<H>(&mut self, handler: H)
pub fn set_module_registrator_handler<H>(&mut self, handler: H)
Set a handler for the port creation
When a port is created, a service should be registered for the port.
Sourcepub fn set_on_transport_closes_handler<H>(&mut self, handler: H)
pub fn set_on_transport_closes_handler<H>(&mut self, handler: H)
Set a handler to be executed when a transport was closed
When a transport closes its connection, the closure will be executed.
This could be useful when there are resources that may be tied to or depends on a transport’s connection
Auto Trait Implementations§
impl<Context, T> Freeze for RpcServer<Context, T>where
T: ?Sized,
impl<Context, T> !RefUnwindSafe for RpcServer<Context, T>
impl<Context, T> Send for RpcServer<Context, T>
impl<Context, T> Sync for RpcServer<Context, T>
impl<Context, T> Unpin for RpcServer<Context, T>where
T: ?Sized,
impl<Context, T> !UnwindSafe for RpcServer<Context, 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more