pub struct MultiplexedConnection { /* private fields */ }Expand description
Multiplexed connection supporting concurrent streams
Implementations§
Source§impl MultiplexedConnection
impl MultiplexedConnection
Sourcepub fn with_max_send_queue_len(max_send_queue_len: usize) -> Self
pub fn with_max_send_queue_len(max_send_queue_len: usize) -> Self
Create a new multiplexed connection with a bounded outbound frame queue.
Sourcepub fn with_max_recv_buffer_bytes(max_recv_buffer_bytes: usize) -> Self
pub fn with_max_recv_buffer_bytes(max_recv_buffer_bytes: usize) -> Self
Create a new multiplexed connection with a bounded receive buffer.
Sourcepub fn with_limits(
max_send_queue_len: usize,
max_recv_buffer_bytes: usize,
) -> Self
pub fn with_limits( max_send_queue_len: usize, max_recv_buffer_bytes: usize, ) -> Self
Create a new multiplexed connection with explicit transport limits.
Sourcepub fn stream_count(&self) -> u16
pub fn stream_count(&self) -> u16
Get current stream count
Sourcepub async fn open_stream(&self) -> Result<u16, MultiplexError>
pub async fn open_stream(&self) -> Result<u16, MultiplexError>
Open a new stream
Sourcepub async fn accept_stream(&self, stream_id: u16) -> Result<(), MultiplexError>
pub async fn accept_stream(&self, stream_id: u16) -> Result<(), MultiplexError>
Accept an incoming stream (called when receiving SYN)
Sourcepub async fn send(
&self,
stream_id: u16,
data: Bytes,
) -> Result<(), MultiplexError>
pub async fn send( &self, stream_id: u16, data: Bytes, ) -> Result<(), MultiplexError>
Send data on a stream
Sourcepub async fn recv(
&self,
stream_id: u16,
) -> Result<Option<Bytes>, MultiplexError>
pub async fn recv( &self, stream_id: u16, ) -> Result<Option<Bytes>, MultiplexError>
Receive data from a stream
Sourcepub async fn close_stream(&self, stream_id: u16) -> Result<(), MultiplexError>
pub async fn close_stream(&self, stream_id: u16) -> Result<(), MultiplexError>
Close a stream gracefully
Sourcepub async fn reset_stream(
&self,
stream_id: u16,
error: Option<String>,
) -> Result<(), MultiplexError>
pub async fn reset_stream( &self, stream_id: u16, error: Option<String>, ) -> Result<(), MultiplexError>
Reset a stream with error
Sourcepub async fn process_frame(
&self,
header: StreamHeader,
payload: Bytes,
) -> Result<(), MultiplexError>
pub async fn process_frame( &self, header: StreamHeader, payload: Bytes, ) -> Result<(), MultiplexError>
Process an incoming frame
Sourcepub async fn take_frame(&self) -> Option<(StreamHeader, Bytes)>
pub async fn take_frame(&self) -> Option<(StreamHeader, Bytes)>
Take next frame to send
Sourcepub fn encode_frame(header: &StreamHeader, payload: &Bytes) -> Bytes
pub fn encode_frame(header: &StreamHeader, payload: &Bytes) -> Bytes
Encode a frame to bytes
Sourcepub async fn stream_status(
&self,
stream_id: u16,
) -> Result<StreamStatus, MultiplexError>
pub async fn stream_status( &self, stream_id: u16, ) -> Result<StreamStatus, MultiplexError>
Get stream status
Sourcepub fn total_bytes_sent(&self) -> u64
pub fn total_bytes_sent(&self) -> u64
Get total bytes sent
Sourcepub fn total_bytes_received(&self) -> u64
pub fn total_bytes_received(&self) -> u64
Get total bytes received
Sourcepub async fn has_stream(&self, stream_id: u16) -> bool
pub async fn has_stream(&self, stream_id: u16) -> bool
Check if a stream exists
Sourcepub async fn active_streams(&self) -> Vec<u16>
pub async fn active_streams(&self) -> Vec<u16>
Get all active stream IDs
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MultiplexedConnection
impl !RefUnwindSafe for MultiplexedConnection
impl !UnwindSafe for MultiplexedConnection
impl Send for MultiplexedConnection
impl Sync for MultiplexedConnection
impl Unpin for MultiplexedConnection
impl UnsafeUnpin for MultiplexedConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more