pub struct ServerBuilder<S> { /* private fields */ }Expand description
A builder for configuring and launching multiple RPC servers from a single service implementation.
This provides a fluent interface to add different protocol servers that all delegate to the same shared service logic.
Implementations§
Source§impl<S> ServerBuilder<S>
impl<S> ServerBuilder<S>
Sourcepub fn new(service: S) -> Self
pub fn new(service: S) -> Self
Creates a new ServerBuilder.
§Arguments
service- The service implementation that will be shared across all protocols.
Sourcepub fn add_protocol<F>(self, factory: F) -> Self
pub fn add_protocol<F>(self, factory: F) -> Self
Adds a protocol server to the builder.
The #[multi_rpc_impl] macro generates protocol-specific factory functions
(e.g., greeter_impls::tarpc_tcp(...)) that can be passed to this method.
§Arguments
factory- A function that takes the shared service instance and returns a future representing the running server task.
Sourcepub fn build(self) -> Result<ServerRunner, Error>
pub fn build(self) -> Result<ServerRunner, Error>
Consumes the builder, spawning all configured protocol servers on the Tokio runtime.
Returns a ServerRunner which can be used to keep the application alive
until a shutdown signal is received.
Auto Trait Implementations§
impl<S> Freeze for ServerBuilder<S>
impl<S> !RefUnwindSafe for ServerBuilder<S>
impl<S> Send for ServerBuilder<S>
impl<S> !Sync for ServerBuilder<S>
impl<S> Unpin for ServerBuilder<S>
impl<S> !UnwindSafe for ServerBuilder<S>
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