pub struct StreamPair<R: RecvStream = RecvStream, W: SendStream = SendStream> { /* private fields */ }
Expand description
A pair of SendStream
and RecvStream
with additional context data.
Implementations§
Source§impl StreamPair
impl StreamPair
pub async fn accept( conn: &Connection, events: EventSender, ) -> Result<Self, ConnectionError>
Source§impl<R: RecvStream, W: SendStream> StreamPair<R, W>
impl<R: RecvStream, W: SendStream> StreamPair<R, W>
pub fn stream_id(&self) -> u64
pub fn new( connection_id: u64, reader: R, writer: W, events: EventSender, ) -> Self
Sourcepub async fn read_request(&mut self) -> Result<Request>
pub async fn read_request(&mut self) -> Result<Request>
Read the request.
Will fail if there is an error while reading, or if no valid request is sent.
This will read exactly the number of bytes needed for the request, and leave the rest of the stream for the caller to read.
It is up to the caller do decide if there should be more data.
Sourcepub async fn into_writer(
self,
tracker: RequestTracker,
) -> Result<ProgressWriter<W>, Error>
pub async fn into_writer( self, tracker: RequestTracker, ) -> Result<ProgressWriter<W>, Error>
We are done with reading. Return a ProgressWriter that contains the read stats and connection id
pub async fn into_reader( self, tracker: RequestTracker, ) -> Result<ProgressReader<R>, Error>
pub async fn get_request( &self, f: impl FnOnce() -> GetRequest, ) -> Result<RequestTracker, ProgressError>
pub async fn get_many_request( &self, f: impl FnOnce() -> GetManyRequest, ) -> Result<RequestTracker, ProgressError>
pub async fn push_request( &self, f: impl FnOnce() -> PushRequest, ) -> Result<RequestTracker, ProgressError>
pub async fn observe_request( &self, f: impl FnOnce() -> ObserveRequest, ) -> Result<RequestTracker, ProgressError>
pub fn stats(&self) -> TransferStats
Trait Implementations§
Source§impl<R: Debug + RecvStream, W: Debug + SendStream> Debug for StreamPair<R, W>
impl<R: Debug + RecvStream, W: Debug + SendStream> Debug for StreamPair<R, W>
Auto Trait Implementations§
impl<R, W> Freeze for StreamPair<R, W>
impl<R = RecvStream, W = SendStream> !RefUnwindSafe for StreamPair<R, W>
impl<R, W> Send for StreamPair<R, W>
impl<R, W> Sync for StreamPair<R, W>
impl<R, W> Unpin for StreamPair<R, W>
impl<R = RecvStream, W = SendStream> !UnwindSafe for StreamPair<R, W>
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