pub struct FileTransferRecord { /* private fields */ }Expand description
Immutable progress/state record emitted by transfer callbacks.
This snapshot is safe to clone and pass across threads. file_sign and
file_name are backed by Arc<str> so per-event fan-out only performs
a refcount bump instead of string allocation.
Implementations§
Source§impl FileTransferRecord
impl FileTransferRecord
Sourcepub fn new(
task_id: TaskId,
file_sign: impl Into<Arc<str>>,
file_name: impl Into<Arc<str>>,
total_size: u64,
progress: f32,
status: TransferStatus,
direction: Direction,
) -> Self
pub fn new( task_id: TaskId, file_sign: impl Into<Arc<str>>, file_name: impl Into<Arc<str>>, total_size: u64, progress: f32, status: TransferStatus, direction: Direction, ) -> Self
Creates a new transfer record.
§Range guidance
total_size >= 0progressshould stay in0.0..=1.0
§Examples
use rusty_cat::api::{Direction, FileTransferRecord, TaskId, TransferStatus};
let record = FileTransferRecord::new(
task_id,
"sign".to_string(),
"file.bin".to_string(),
1024,
0.5,
TransferStatus::Transmission,
Direction::Download,
);
assert_eq!(record.total_size(), 1024);Sourcepub fn file_sign(&self) -> &str
pub fn file_sign(&self) -> &str
Returns file signature.
§Examples
use rusty_cat::api::FileTransferRecord;
fn read_sign(record: &FileTransferRecord) {
let _ = record.file_sign();
}Sourcepub fn file_name(&self) -> &str
pub fn file_name(&self) -> &str
Returns display file name.
§Examples
use rusty_cat::api::FileTransferRecord;
fn read_name(record: &FileTransferRecord) {
let _ = record.file_name();
}Sourcepub fn total_size(&self) -> u64
pub fn total_size(&self) -> u64
Returns total file size in bytes.
§Examples
use rusty_cat::api::FileTransferRecord;
fn read_size(record: &FileTransferRecord) {
let _ = record.total_size();
}Sourcepub fn progress(&self) -> f32
pub fn progress(&self) -> f32
Returns progress ratio in range 0.0..=1.0.
§Examples
use rusty_cat::api::FileTransferRecord;
fn read_progress(record: &FileTransferRecord) {
let _ = record.progress();
}Sourcepub fn status(&self) -> &TransferStatus
pub fn status(&self) -> &TransferStatus
Returns current transfer status.
§Examples
use rusty_cat::api::FileTransferRecord;
fn read_status(record: &FileTransferRecord) {
let _ = record.status();
}Trait Implementations§
Source§impl Clone for FileTransferRecord
impl Clone for FileTransferRecord
Source§fn clone(&self) -> FileTransferRecord
fn clone(&self) -> FileTransferRecord
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FileTransferRecord
impl !RefUnwindSafe for FileTransferRecord
impl Send for FileTransferRecord
impl Sync for FileTransferRecord
impl Unpin for FileTransferRecord
impl UnsafeUnpin for FileTransferRecord
impl !UnwindSafe for FileTransferRecord
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