pub struct Grpc<T> { /* private fields */ }
Expand description

A gRPC Server handler.

This will wrap some inner Codec and provide utilities to handle inbound unary, client side streaming, server side streaming, and bi-directional streaming.

Each request handler method accepts some service that implements the corresponding service trait and a http request that contains some body that implements some Body.

Implementations

Creates a new gRPC server with the provided Codec.

Enable accepting compressed requests.

If a request with an unsupported encoding is received the server will respond with Code::UnUnimplemented.

Example

The most common way of using this is through a server generated by tonic-build:


#[tonic::async_trait]
impl Example for Svc {
    // ...
}

let service = ExampleServer::new(Svc).accept_compressed(CompressionEncoding::Gzip);

Enable sending compressed responses.

Requires the client to also support receiving compressed responses.

Example

The most common way of using this is through a server generated by tonic-build:


#[tonic::async_trait]
impl Example for Svc {
    // ...
}

let service = ExampleServer::new(Svc).send_compressed(CompressionEncoding::Gzip);

Limits the maximum size of a decoded message.

Example

The most common way of using this is through a server generated by tonic-build:


#[tonic::async_trait]
impl Example for Svc {
    // ...
}

// Set the limit to 2MB, Defaults to 4MB.
let limit = 2 * 1024 * 1024;
let service = ExampleServer::new(Svc).max_decoding_message_size(limit);

Limits the maximum size of a encoded message.

Example

The most common way of using this is through a server generated by tonic-build:


#[tonic::async_trait]
impl Example for Svc {
    // ...
}

// Set the limit to 2MB, Defaults to 4MB.
let limit = 2 * 1024 * 1024;
let service = ExampleServer::new(Svc).max_encoding_message_size(limit);

Handle a single unary gRPC request.

Handle a server side streaming request.

Handle a client side streaming gRPC request.

Handle a bi-directional streaming gRPC request.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more