pub struct GrpcConnection { /* private fields */ }Expand description
Sans-IO gRPC client connection wrapping an H2Connection.
Implementations§
Source§impl GrpcConnection
impl GrpcConnection
Sourcepub fn new(settings: Settings) -> Self
pub fn new(settings: Settings) -> Self
Create a new gRPC connection with the given HTTP/2 settings.
Sourcepub fn set_max_message_size(&mut self, n: usize)
pub fn set_max_message_size(&mut self, n: usize)
Override the cap on a single received gRPC message. Defaults to
4 MiB. Applied to the length-prefix decode (raw frame size) and to
the decompressed output if grpc-encoding is set.
Sourcepub fn recv(&mut self, data: &[u8]) -> Result<(), GrpcError>
pub fn recv(&mut self, data: &[u8]) -> Result<(), GrpcError>
Feed received bytes from the transport.
Sourcepub fn poll_event(&mut self) -> Option<GrpcEvent>
pub fn poll_event(&mut self) -> Option<GrpcEvent>
Poll the next gRPC event, if any.
Sourcepub fn take_pending_send(&mut self) -> Vec<u8> ⓘ
pub fn take_pending_send(&mut self) -> Vec<u8> ⓘ
Take all pending bytes to send to the transport.
Sourcepub fn has_pending_send(&self) -> bool
pub fn has_pending_send(&self) -> bool
Whether there are bytes pending to send.
Sourcepub fn send_unary(
&mut self,
service: &str,
method: &str,
body: &[u8],
metadata: &[HeaderField],
) -> Result<u32, GrpcError>
pub fn send_unary( &mut self, service: &str, method: &str, body: &[u8], metadata: &[HeaderField], ) -> Result<u32, GrpcError>
Send a unary gRPC request (headers + length-prefixed body + end_stream).
Returns the stream ID. Fails with GrpcError::NotReady if the HTTP/2
settings exchange hasn’t completed yet — sending before SETTINGS ACK
can violate frame-size or stream-concurrency limits the server is
about to advertise.
Sourcepub fn send_unary_with_deadline(
&mut self,
service: &str,
method: &str,
body: &[u8],
metadata: &[HeaderField],
deadline: Duration,
) -> Result<u32, GrpcError>
pub fn send_unary_with_deadline( &mut self, service: &str, method: &str, body: &[u8], metadata: &[HeaderField], deadline: Duration, ) -> Result<u32, GrpcError>
Same as send_unary but also encodes a
grpc-timeout header so the server knows when to cancel work on
the application’s behalf. The encoded timeout uses the smallest
gRPC unit (n/u/m/S/M/H) that fits the value in ≤ 8 digits per
the gRPC spec. Note: this only advertises the deadline to the
server. Client-side enforcement (cancel + emit Status with
DeadlineExceeded) is the caller’s responsibility.
Sourcepub fn start_request(
&mut self,
service: &str,
method: &str,
metadata: &[HeaderField],
) -> Result<u32, GrpcError>
pub fn start_request( &mut self, service: &str, method: &str, metadata: &[HeaderField], ) -> Result<u32, GrpcError>
Start a streaming gRPC request (headers only, no end_stream).
Returns the stream ID. Use send_message() to send body frames.
Fails with GrpcError::NotReady if the HTTP/2 settings exchange
hasn’t completed yet.