morpheus_network::transfer::chunked

Struct ChunkedDecoder

Source
pub struct ChunkedDecoder {
    state: DecoderState,
    size_buffer: Vec<u8>,
    current_chunk_size: usize,
    chunk_bytes_read: usize,
    output: Vec<u8>,
}
Expand description

Chunked transfer encoding decoder.

Handles incremental decoding for streaming scenarios.

Fields§

§state: DecoderState

Current decoder state.

§size_buffer: Vec<u8>

Buffer for incomplete chunk size line.

§current_chunk_size: usize

Expected size of current chunk.

§chunk_bytes_read: usize

Bytes read in current chunk.

§output: Vec<u8>

Decoded output data.

Implementations§

Source§

impl ChunkedDecoder

Source

pub fn new() -> Self

Create a new chunked decoder.

Source

pub fn state(&self) -> DecoderState

Get current decoder state.

Source

pub fn is_done(&self) -> bool

Check if decoding is complete.

Source

pub fn output(&self) -> &[u8]

Get decoded output (only valid when done).

Source

pub fn take_output(self) -> Vec<u8>

Take ownership of the decoded output.

Source

pub fn decode(data: &[u8]) -> Result<Vec<u8>>

Decode a complete chunked body in one go.

Returns the decoded data.

Source

pub fn feed(&mut self, data: &[u8]) -> Result<usize>

Feed data to the decoder incrementally.

Returns the number of bytes consumed.

Source

fn parse_chunk_size(&mut self) -> Result<()>

Parse the chunk size from size_buffer.

Source

pub fn reset(&mut self)

Reset the decoder to initial state.

Trait Implementations§

Source§

impl Debug for ChunkedDecoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChunkedDecoder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.