Skip to main content

GrpcConnection

Struct GrpcConnection 

Source
pub struct GrpcConnection { /* private fields */ }
Expand description

Sans-IO gRPC client connection wrapping an H2Connection.

Implementations§

Source§

impl GrpcConnection

Source

pub fn new(settings: Settings) -> Self

Create a new gRPC connection with the given HTTP/2 settings.

Source

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.

Source

pub fn recv(&mut self, data: &[u8]) -> Result<(), GrpcError>

Feed received bytes from the transport.

Source

pub fn poll_event(&mut self) -> Option<GrpcEvent>

Poll the next gRPC event, if any.

Source

pub fn take_pending_send(&mut self) -> Vec<u8>

Take all pending bytes to send to the transport.

Source

pub fn has_pending_send(&self) -> bool

Whether there are bytes pending to send.

Source

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.

Source

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.

Source

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.

Source

pub fn send_message( &mut self, stream_id: u32, body: &[u8], end_stream: bool, ) -> Result<(), GrpcError>

Send a gRPC message on an open stream.

Source

pub fn cancel(&mut self, stream_id: u32)

Cancel a stream with RST_STREAM CANCEL. Pushes a terminal Status::Cancelled event so any caller awaiting completion observes the cancellation rather than hanging.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.