pub struct RemoteServer<L: AsyncLink, F: Fn() -> L> { /* private fields */ }Available on crate feature
server only.Expand description
A server that accepts connections from Remote clients and forwards requests to a link.
Implementations§
Source§impl<L: AsyncLink, F: Fn() -> L> RemoteServer<L, F>
impl<L: AsyncLink, F: Fn() -> L> RemoteServer<L, F>
Sourcepub const fn new(port: u16, link_factory: F) -> Self
pub const fn new(port: u16, link_factory: F) -> Self
Create a new RemoteServer.
§Arguments
port- The port to listen onlink- A factory function that creates a new link instance
Sourcepub fn with_graceful_shutdown<S>(self, signal: S) -> Self
pub fn with_graceful_shutdown<S>(self, signal: S) -> Self
Configure graceful shutdown with a custom shutdown signal.
§Arguments
signal- A future that completes when the server should shut down
Sourcepub async fn run(&mut self) -> Result<(), LinkError>
pub async fn run(&mut self) -> Result<(), LinkError>
Run the server.
This method listens for incoming connections asynchronously. For each connection, it processes requests and forwards them to the link.
If a shutdown signal is configured via with_graceful_shutdown,
the server will gracefully shut down when the signal completes.
§Errors
Returns an error if:
- Failed to bind to the specified port
- Failed to accept a connection
- Failed to process a request
Auto Trait Implementations§
impl<L, F> Freeze for RemoteServer<L, F>
impl<L, F> !RefUnwindSafe for RemoteServer<L, F>
impl<L, F> Send for RemoteServer<L, F>where
F: Send,
impl<L, F> !Sync for RemoteServer<L, F>
impl<L, F> Unpin for RemoteServer<L, F>
impl<L, F> !UnwindSafe for RemoteServer<L, F>
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