Skip to main content

GrpcSession

Struct GrpcSession 

Source
pub struct GrpcSession<Role> { /* private fields */ }
Expand description

Single-threaded session. Closed slots remain readable until explicitly removed.

Implementations§

Source§

impl GrpcSession<Client>

Source

pub fn new(config: SessionConfig) -> Result<Self, Status>

Creates an engine and queues its initial HTTP/2 SETTINGS.

§Errors

Rejects invalid settings and protocol initialization failure.

Source§

impl GrpcSession<Server>

Source

pub fn new(config: SessionConfig) -> Result<Self, Status>

Creates an engine and queues its initial HTTP/2 SETTINGS.

§Errors

Rejects invalid settings and protocol initialization failure.

Source§

impl GrpcSession<Client>

Source

pub fn start_request( &mut self, authority: &str, path: &str, metadata: &Metadata, timeout: Option<Timeout>, encoding: CompressionAlgorithm, end_stream: bool, ) -> Result<i32, Status>

Starts a POST request; false END_STREAM enables incremental message sending.

§Errors

Rejects stream limits, invalid metadata/timeout or protocol submission failure.

Source

pub fn start_request_with_content_type( &mut self, authority: &str, path: &str, metadata: &Metadata, timeout: Option<Timeout>, encoding: CompressionAlgorithm, end_stream: bool, content_type: &str, ) -> Result<i32, Status>

Starts a request with a codec media type independently of other RPCs.

§Errors

Rejects invalid media types, metadata, stream limits or protocol submission failure.

Source

pub fn half_close(&mut self, id: i32) -> Result<(), Status>

Ends the request body after all queued messages.

§Errors

Rejects unknown, reset or already half-closed streams.

Source§

impl GrpcSession<Server>

Source

pub fn reap_closed_undispatched_streams(&mut self) -> Result<usize, Status>

Releases safely closed streams that were never handed to a request consumer. Dispatched streams retain their terminal state until explicitly removed.

§Errors

Returns a stream-removal error if its closure state is inconsistent.

Source

pub fn pop_incoming_request(&mut self) -> Option<IncomingRequest>

Transfers the next received request’s routing information.

Source

pub fn send_initial_metadata( &mut self, id: i32, metadata: &Metadata, encoding: CompressionAlgorithm, ) -> Result<(), Status>

Sends response headers and installs an incremental body source.

§Errors

Rejects duplicate headers, ended streams and protocol submission failure.

Source

pub fn send_initial_metadata_with_content_type( &mut self, id: i32, metadata: &Metadata, encoding: CompressionAlgorithm, content_type: &str, ) -> Result<(), Status>

Starts a response using the codec selected for this RPC’s route.

§Errors

Rejects invalid media types, duplicate headers, ended streams or protocol failure.

Source

pub fn finish_response( &mut self, id: i32, status: &Status, metadata: &Metadata, ) -> Result<(), Status>

Completes a response, emitting trailers only when its queued DATA has drained.

§Errors

Rejects duplicate completion, invalid streams, budgets or protocol failure.

Source§

impl<Role> GrpcSession<Role>

Source

pub fn submit_goaway(&mut self, error_code: u32) -> Result<(), Status>

Queues GOAWAY at the last processed peer stream; existing RPCs may finish.

§Errors

Returns protocol submission or a previous connection failure.

Source

pub fn want_read(&self) -> bool

Whether the protocol connection can accept additional inbound bytes.

Source

pub fn want_write(&self) -> bool

Whether protocol frames or partially written transport bytes need sending.

Source

pub fn goaway_received(&self) -> Option<(i32, u32)>

The most restrictive peer GOAWAY boundary and its HTTP/2 error code.

Source

pub fn stream_outbound_complete(&self, id: i32) -> bool

Whether terminal output was serialized and tracked transport writes/flushes drained.

Source

pub fn is_draining(&self) -> bool

Whether local or peer GOAWAY has stopped admission of new RPCs.

Source

pub fn send_message( &mut self, id: i32, payload: &[u8], encoding: CompressionAlgorithm, ) -> Result<(), Status>

Queues one framed message, preserving the stream’s negotiated encoding.

§Errors

Rejects ended streams, mismatched encodings, compression failure or byte excess.

Source

pub fn cancel_stream(&mut self, id: i32, error_code: u32) -> Result<(), Status>

Resets a stream and releases its queued outbound body. Completed NO_ERROR peer closure needs no additional local upload reset.

§Errors

Rejects unknown streams or protocol reset submission failure.

Source

pub fn mem_recv(&mut self, bytes: &[u8]) -> Result<usize, Status>

Feeds received HTTP/2 bytes and dispatches every resulting callback event.

§Errors

Returns protocol connection errors; malformed RPC streams are reset individually.

Source

pub fn mem_send(&mut self) -> Result<&[u8], Status>

Produces the next HTTP/2 wire chunk, valid until the next mutable session call.

§Errors

Returns protocol connection or callback-processing errors.

Source

pub fn flush_to_transport<T: SyncTransport>( &mut self, transport: &mut T, ) -> Result<(), Status>

Flushes wire output, retaining partially written chunks across WouldBlock.

§Errors

Returns transport or session failures; WouldBlock means retry later.

Source

pub fn step_transport<T: SyncTransport>( &mut self, transport: &mut T, buf: &mut [u8], ) -> Result<usize, Status>

Flushes outgoing data, reads once and routes inbound bytes.

§Errors

Returns transport EOF/errors or session errors. WouldBlock returns zero.

Source

pub fn pop_initial_metadata( &mut self, id: i32, ) -> Result<Option<Metadata>, Status>

Transfers custom initial metadata, preserving stream lifecycle history.

§Errors

Returns unknown/reset stream or metadata decoding errors.

Source

pub fn pop_message( &mut self, id: i32, ) -> Result<Option<AlignedMessageBuf>, Status>

Transfers one decompressed message into eight-byte-aligned storage.

§Errors

Returns unknown/reset stream or allocation errors.

Source

pub fn is_remote_end_stream(&self, id: i32) -> Result<bool, Status>

Whether the peer’s request or response half has ended.

§Errors

Returns unknown/reset stream errors.

Source

pub fn take_trailers( &mut self, id: i32, ) -> Result<Option<(Status, Metadata)>, Status>

Takes terminal status and custom trailing metadata exactly once.

§Errors

Returns unknown/reset stream or invalid metadata errors.

Source

pub fn remove_closed_stream(&mut self, id: i32) -> Result<(), Status>

Releases a closed stream and all unread events.

§Errors

Rejects unknown or still-open streams.

Auto Trait Implementations§

§

impl<Role> !RefUnwindSafe for GrpcSession<Role>

§

impl<Role> !Send for GrpcSession<Role>

§

impl<Role> !Sync for GrpcSession<Role>

§

impl<Role> !UnwindSafe for GrpcSession<Role>

§

impl<Role> Freeze for GrpcSession<Role>
where PhantomData<Role>: Freeze,

§

impl<Role> Unpin for GrpcSession<Role>
where PhantomData<Role>: Unpin,

§

impl<Role> UnsafeUnpin for GrpcSession<Role>
where PhantomData<Role>: UnsafeUnpin,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.