pub struct StreamHandler { /* private fields */ }Expand description
Handler for an individual QUIC stream (bidirectional)
Implementations§
Source§impl StreamHandler
impl StreamHandler
pub fn new(send: SendStream, recv: RecvStream) -> Self
Sourcepub async fn read_frame(&mut self) -> Result<Frame, ServerError>
pub async fn read_frame(&mut self) -> Result<Frame, ServerError>
Read the next frame from the stream
Sourcepub async fn write_frame(&mut self, frame: &Frame) -> Result<(), ServerError>
pub async fn write_frame(&mut self, frame: &Frame) -> Result<(), ServerError>
Write a frame to the stream
Sourcepub async fn handle_request<Req, Resp, H, Fut>(
&mut self,
handler: H,
) -> Result<(), ServerError>
pub async fn handle_request<Req, Resp, H, Fut>( &mut self, handler: H, ) -> Result<(), ServerError>
Handle a request/response pattern
Sourcepub fn into_framed(self) -> FramedStream<(SendStream, RecvStream)>
pub fn into_framed(self) -> FramedStream<(SendStream, RecvStream)>
Convert to a FramedStream for more complex patterns
Sourcepub fn finish(&mut self) -> Result<(), ServerError>
pub fn finish(&mut self) -> Result<(), ServerError>
Finish the send stream (signal no more data)
Sourcepub async fn read_bytes(&mut self, buf: &mut [u8]) -> Result<usize, ServerError>
pub async fn read_bytes(&mut self, buf: &mut [u8]) -> Result<usize, ServerError>
Read raw bytes from the stream (for streaming uploads) Returns the number of bytes read, or 0 if EOF
Sourcepub async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ServerError>
pub async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ServerError>
Read exact number of bytes from the stream
Sourcepub async fn read_to_end(
&mut self,
size_limit: usize,
) -> Result<Vec<u8>, ServerError>
pub async fn read_to_end( &mut self, size_limit: usize, ) -> Result<Vec<u8>, ServerError>
Read all remaining bytes from the stream until EOF (with size limit)
Sourcepub async fn stream_to_writer<W: AsyncWrite + Unpin>(
&mut self,
writer: &mut W,
expected_size: Option<u64>,
) -> Result<u64, ServerError>
pub async fn stream_to_writer<W: AsyncWrite + Unpin>( &mut self, writer: &mut W, expected_size: Option<u64>, ) -> Result<u64, ServerError>
Stream bytes to a writer (for large uploads without buffering all in memory)
Auto Trait Implementations§
impl Freeze for StreamHandler
impl RefUnwindSafe for StreamHandler
impl Send for StreamHandler
impl Sync for StreamHandler
impl Unpin for StreamHandler
impl UnwindSafe for StreamHandler
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