morpheus_network::transfer::streaming

Struct StreamWriter

Source
pub struct StreamWriter {
    total_size: usize,
    bytes_sent: usize,
    chunk_size: usize,
    progress_callback: Option<ProgressCallback>,
    progress_interval: usize,
    bytes_since_progress: usize,
}
Expand description

Streaming writer for sending data in chunks.

Used for POST/PUT requests with large bodies.

Fields§

§total_size: usize

Total bytes to send.

§bytes_sent: usize

Bytes sent so far.

§chunk_size: usize

Chunk size for sending.

§progress_callback: Option<ProgressCallback>

Progress callback.

§progress_interval: usize

Progress reporting interval.

§bytes_since_progress: usize

Bytes since last progress report.

Implementations§

Source§

impl StreamWriter

Source

pub fn new(total_size: usize, chunk_size: usize) -> Self

Create a new stream writer.

§Arguments
  • total_size - Total bytes to be sent
  • chunk_size - Size of each chunk to send
Source

pub fn set_progress_callback(&mut self, callback: ProgressCallback)

Set progress callback.

Source

pub fn next_chunk<'a>(&mut self, source: &'a [u8]) -> Option<&'a [u8]>

Get next chunk to send from source data.

Returns slice of data for next chunk, or None if complete.

Source

pub fn chunk_sent(&mut self, bytes: usize)

Mark chunk as sent.

Source

pub fn is_complete(&self) -> bool

Check if all data has been sent.

Source

pub fn bytes_sent(&self) -> usize

Get bytes sent so far.

Source

pub fn remaining(&self) -> usize

Get remaining bytes.

Source

pub fn progress_percent(&self) -> u8

Get progress percentage.

Source

fn report_progress(&self)

Report progress via callback.

Trait Implementations§

Source§

impl Debug for StreamWriter

Source§

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

Formats the value using the given formatter. 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.