pub struct ConnectFrameDecoder { /* private fields */ }Expand description
Streaming decoder for Connect frames from a byte source.
Handles split chunks, multiple frames in a single chunk, and malformed
(oversized) lengths. Does NOT handle gzip decompression inline – the
caller checks FLAG_GZIP and decompresses if desired.
End frames (FLAG_END set) with an empty or JSON payload are returned as ConnectFrames. The caller inspects the payload to determine whether it conveys a Connect error.
Implementations§
Source§impl ConnectFrameDecoder
impl ConnectFrameDecoder
pub fn new() -> Self
Sourcepub fn push(
&mut self,
chunk: impl AsRef<[u8]>,
) -> Result<Vec<ConnectFrame>, ConnectError>
pub fn push( &mut self, chunk: impl AsRef<[u8]>, ) -> Result<Vec<ConnectFrame>, ConnectError>
Feed bytes into the decoder. Returns all complete frames found.
Returns an error if a frame header advertises a length that exceeds
max_frame_payload (default 64 MiB).
Sourcepub fn push_with_limit(
&mut self,
chunk: impl AsRef<[u8]>,
max_payload: usize,
) -> Result<Vec<ConnectFrame>, ConnectError>
pub fn push_with_limit( &mut self, chunk: impl AsRef<[u8]>, max_payload: usize, ) -> Result<Vec<ConnectFrame>, ConnectError>
Same as push but with an explicit max_payload limit for testing.
Trait Implementations§
Source§impl Default for ConnectFrameDecoder
impl Default for ConnectFrameDecoder
Source§fn default() -> ConnectFrameDecoder
fn default() -> ConnectFrameDecoder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConnectFrameDecoder
impl RefUnwindSafe for ConnectFrameDecoder
impl Send for ConnectFrameDecoder
impl Sync for ConnectFrameDecoder
impl Unpin for ConnectFrameDecoder
impl UnsafeUnpin for ConnectFrameDecoder
impl UnwindSafe for ConnectFrameDecoder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more