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: usizeTotal bytes to send.
bytes_sent: usizeBytes sent so far.
chunk_size: usizeChunk size for sending.
progress_callback: Option<ProgressCallback>Progress callback.
progress_interval: usizeProgress reporting interval.
bytes_since_progress: usizeBytes since last progress report.
Implementations§
Source§impl StreamWriter
impl StreamWriter
Sourcepub fn new(total_size: usize, chunk_size: usize) -> Self
pub fn new(total_size: usize, chunk_size: usize) -> Self
Create a new stream writer.
§Arguments
total_size- Total bytes to be sentchunk_size- Size of each chunk to send
Sourcepub fn set_progress_callback(&mut self, callback: ProgressCallback)
pub fn set_progress_callback(&mut self, callback: ProgressCallback)
Set progress callback.
Sourcepub fn next_chunk<'a>(&mut self, source: &'a [u8]) -> Option<&'a [u8]>
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.
Sourcepub fn chunk_sent(&mut self, bytes: usize)
pub fn chunk_sent(&mut self, bytes: usize)
Mark chunk as sent.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if all data has been sent.
Sourcepub fn bytes_sent(&self) -> usize
pub fn bytes_sent(&self) -> usize
Get bytes sent so far.
Sourcepub fn progress_percent(&self) -> u8
pub fn progress_percent(&self) -> u8
Get progress percentage.
Sourcefn report_progress(&self)
fn report_progress(&self)
Report progress via callback.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamWriter
impl RefUnwindSafe for StreamWriter
impl Send for StreamWriter
impl Sync for StreamWriter
impl Unpin for StreamWriter
impl UnwindSafe for StreamWriter
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