Expand description
Streaming transfer handler for large downloads.
Provides incremental data transfer with:
- Progress callbacks for UI updates
- Cancellation support
- Memory-efficient streaming (no full buffering)
- Automatic chunk size management
§Architecture
┌─────────────┐ ┌──────────────┐ ┌──────────────┐
│ Data Source │────▶│ StreamReader │────▶│ Sink/Output │
│ (HTTP) │ │ (progress) │ │ (file/buffer)│
└─────────────┘ └──────────────┘ └──────────────┘§Examples
ⓘ
use morpheus_network::transfer::StreamReader;
let mut reader = StreamReader::new(1024 * 64); // 64KB chunks
reader.set_expected_size(Some(1024 * 1024)); // 1MB expected
reader.set_progress_callback(|transferred, total| {
println!("Progress: {}/{:?}", transferred, total);
});
while !reader.is_complete() {
let chunk = fetch_next_chunk();
reader.feed(&chunk)?;
}Structs§
- Progress tracker for transfers.
- Configuration for streaming transfers.
- Streaming data reader with progress tracking.
- Streaming writer for sending data in chunks.
Enums§
- State of a streaming transfer.