pub struct Server { /* private fields */ }Expand description
A ttrpc server.
Implementations§
Source§impl Server
impl Server
Sourcepub async fn run_grpc(
&mut self,
driver: &(impl Driver + ?Sized),
listener: impl Listener,
cancel: OneshotReceiver<()>,
) -> Result<()>
pub async fn run_grpc( &mut self, driver: &(impl Driver + ?Sized), listener: impl Listener, cancel: OneshotReceiver<()>, ) -> Result<()>
Runs the server using the gRPC transport, listening on listener and servicing connections until
cancel.
Sourcepub async fn serve_connection_grpc(
&self,
stream: PolledSocket<impl AsSockRef + Read + Write>,
) -> Result<()>
pub async fn serve_connection_grpc( &self, stream: PolledSocket<impl AsSockRef + Read + Write>, ) -> Result<()>
Services a single, already-accepted connection using the gRPC (HTTP/2) protocol.
This is useful when the caller owns the accept loop, for example to dispatch a connection to gRPC or another protocol based on a sniffed prefix byte.
Source§impl Server
impl Server
Sourcepub fn add_service<T: ServiceRpc>(&mut self) -> RpcReceiver<T>
pub fn add_service<T: ServiceRpc>(&mut self) -> RpcReceiver<T>
Adds or updates a channel for receiving service requests.
Sourcepub async fn run(
&mut self,
driver: &(impl Driver + ?Sized),
listener: impl Listener,
cancel: OneshotReceiver<()>,
) -> Result<()>
pub async fn run( &mut self, driver: &(impl Driver + ?Sized), listener: impl Listener, cancel: OneshotReceiver<()>, ) -> Result<()>
Runs the server using the ttrpc transport, listening on listener and
servicing connections until cancel.
Sourcepub async fn run_single(
&mut self,
driver: &(impl Driver + ?Sized),
conn: impl AsSockRef + Read + Write,
) -> Result<()>
pub async fn run_single( &mut self, driver: &(impl Driver + ?Sized), conn: impl AsSockRef + Read + Write, ) -> Result<()>
Runs the server, servicing a single connection conn.
Sourcepub async fn serve_connection(
&self,
stream: PolledSocket<impl AsSockRef + Read + Write>,
) -> Result<()>
pub async fn serve_connection( &self, stream: PolledSocket<impl AsSockRef + Read + Write>, ) -> Result<()>
Services a single, already-accepted connection using the ttrpc protocol.
This is useful when the caller owns the accept loop, for example to dispatch a connection to ttrpc or another protocol based on a sniffed prefix byte.