Struct VarIntDecoder
pub struct VarIntDecoder { /* private fields */ }quic only.Expand description
Incremental, fragmentation-safe decoder for a single QUIC variable-length integer.
VarInt’s Codec::decode consumes the leading byte before it
can report that a multi-byte integer was truncated, so retrying it on input delivered in
arbitrary chunks — an HTTP/3 stream, for instance — silently loses framing. This decoder retains
partial state across calls instead: feed it whatever bytes are currently available and it
consumes only the bytes belonging to the integer, returning None when it needs more. It
never consumes a byte it cannot account for, so the same decoder can be driven from
non-contiguous buffers. After it returns Some, it resets and is ready for the next integer.
Implementations§
§impl VarIntDecoder
impl VarIntDecoder
pub const fn new() -> VarIntDecoder
pub const fn new() -> VarIntDecoder
Create a decoder with no buffered state.
pub const fn in_progress(&self) -> bool
pub const fn in_progress(&self) -> bool
Whether bytes of an in-progress integer are buffered.
A caller that reaches end of input while this is true holds a truncated integer and should
treat it as a framing error rather than a clean end.
pub fn decode<B>(&mut self, r: &mut B) -> Option<VarInt>where
B: Buf,
pub fn decode<B>(&mut self, r: &mut B) -> Option<VarInt>where
B: Buf,
Feed the currently available bytes.
Consumes only the bytes belonging to the integer being decoded. Returns Some(value) once a
complete integer has been read (resetting for reuse), or None if more input is required, in
which case the buffered progress is retained for the next call.
Trait Implementations§
§impl Clone for VarIntDecoder
impl Clone for VarIntDecoder
§fn clone(&self) -> VarIntDecoder
fn clone(&self) -> VarIntDecoder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for VarIntDecoder
impl Debug for VarIntDecoder
§impl Default for VarIntDecoder
impl Default for VarIntDecoder
§fn default() -> VarIntDecoder
fn default() -> VarIntDecoder
Auto Trait Implementations§
impl Freeze for VarIntDecoder
impl RefUnwindSafe for VarIntDecoder
impl Send for VarIntDecoder
impl Sync for VarIntDecoder
impl Unpin for VarIntDecoder
impl UnsafeUnpin for VarIntDecoder
impl UnwindSafe for VarIntDecoder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more