96 lines
2.3 KiB
Rust
96 lines
2.3 KiB
Rust
|
|
use crate::integrity::IntegrityState;
|
||
|
|
|
||
|
|
/// Monotonic transfer progress observed by the copy loop.
|
||
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||
|
|
pub struct TransferProgress {
|
||
|
|
/// Absolute completed bytes, including `initial_completed_bytes`.
|
||
|
|
completed_bytes: u64,
|
||
|
|
/// Bytes written during this copy invocation only.
|
||
|
|
session_bytes: u64,
|
||
|
|
total_bytes: Option<u64>,
|
||
|
|
completed_members: u64,
|
||
|
|
total_members: Option<u64>,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl TransferProgress {
|
||
|
|
#[must_use]
|
||
|
|
pub fn new(
|
||
|
|
completed_bytes: u64,
|
||
|
|
session_bytes: u64,
|
||
|
|
total_bytes: Option<u64>,
|
||
|
|
completed_members: u64,
|
||
|
|
total_members: Option<u64>,
|
||
|
|
) -> Self {
|
||
|
|
Self {
|
||
|
|
completed_bytes,
|
||
|
|
session_bytes,
|
||
|
|
total_bytes,
|
||
|
|
completed_members,
|
||
|
|
total_members,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[must_use]
|
||
|
|
pub fn completed_bytes(&self) -> u64 {
|
||
|
|
self.completed_bytes
|
||
|
|
}
|
||
|
|
|
||
|
|
#[must_use]
|
||
|
|
pub fn session_bytes(&self) -> u64 {
|
||
|
|
self.session_bytes
|
||
|
|
}
|
||
|
|
|
||
|
|
#[must_use]
|
||
|
|
pub fn total_bytes(&self) -> Option<u64> {
|
||
|
|
self.total_bytes
|
||
|
|
}
|
||
|
|
|
||
|
|
#[must_use]
|
||
|
|
pub fn completed_members(&self) -> u64 {
|
||
|
|
self.completed_members
|
||
|
|
}
|
||
|
|
|
||
|
|
#[must_use]
|
||
|
|
pub fn total_members(&self) -> Option<u64> {
|
||
|
|
self.total_members
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Checkpoint boundary emitted when retained progress should be durable.
|
||
|
|
///
|
||
|
|
/// Concrete source and destination proofs are adapter-owned. Integrity covers
|
||
|
|
/// every byte hashed by the accountant supplied to the copy (prior seed plus
|
||
|
|
/// this session). Absolute digests require a seed whose `bytes_hashed` equals
|
||
|
|
/// `initial_completed_bytes`.
|
||
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||
|
|
pub struct TransferCheckpoint {
|
||
|
|
completed_bytes: u64,
|
||
|
|
session_bytes: u64,
|
||
|
|
integrity: IntegrityState,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl TransferCheckpoint {
|
||
|
|
#[must_use]
|
||
|
|
pub fn new(completed_bytes: u64, session_bytes: u64, integrity: IntegrityState) -> Self {
|
||
|
|
Self {
|
||
|
|
completed_bytes,
|
||
|
|
session_bytes,
|
||
|
|
integrity,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[must_use]
|
||
|
|
pub fn completed_bytes(&self) -> u64 {
|
||
|
|
self.completed_bytes
|
||
|
|
}
|
||
|
|
|
||
|
|
#[must_use]
|
||
|
|
pub fn session_bytes(&self) -> u64 {
|
||
|
|
self.session_bytes
|
||
|
|
}
|
||
|
|
|
||
|
|
#[must_use]
|
||
|
|
pub fn integrity(&self) -> &IntegrityState {
|
||
|
|
&self.integrity
|
||
|
|
}
|
||
|
|
}
|