Expand description
Transfer progress tracking, pause/resume/cancel controls, and typed transfer errors.
§Typed errors
Transfer operations return Result<_, TransferError> so callers can tell a
user cancellation apart from a network failure without matching on error strings:
use ferogram::{Client, TransferHandle, TransferError, InvocationErrorExt};
let handle = TransferHandle::new();
let mut buf = Vec::new();
match client.download(&media, &mut buf, Some(&handle)).await {
Ok(_) => {}
Err(e) if matches!(e.kind(), ferogram::ErrorKind::Transfer) => println!("transfer error: {}", e.friendly()),
Err(e) => println!("other: {e}"),
}TransferError implements From<TransferError> for InvocationError, so
existing call sites using ? on Result<_, InvocationError> compile without changes.
§Example
use ferogram::{Client, TransferHandle};
let handle = TransferHandle::new();
let ctl = handle.clone();
// Spawn a task that cancels after 5 seconds
tokio::spawn(async move {
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
ctl.cancel();
});
let uploaded = client
.upload_file("/tmp/video.mp4")
.handle(&handle)
.await?;Structs§
- Transfer
Handle - Shared control block for a running transfer.
- Transfer
Progress - A snapshot of transfer progress at a single point in time.
Enums§
- Transfer
Error - Typed error returned by upload and download operations.