pub struct ProgressTracker { /* private fields */ }Expand description
进度追踪器
线程安全的进度追踪器,支持多个订阅者。
§Example
use unistore_progress::ProgressTracker;
let tracker = ProgressTracker::new(100);
tracker.advance(10);
tracker.set_message("处理中...");
assert_eq!(tracker.current(), 10);Implementations§
Source§impl ProgressTracker
impl ProgressTracker
Sourcepub fn with_config(total: u64, config: ProgressConfig) -> Self
pub fn with_config(total: u64, config: ProgressConfig) -> Self
使用自定义配置创建进度追踪器
Sourcepub fn percentage(&self) -> f64
pub fn percentage(&self) -> f64
获取完成百分比(0.0 - 100.0)
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
是否已完成
Sourcepub fn set_message(&self, message: impl Into<String>)
pub fn set_message(&self, message: impl Into<String>)
设置进度消息
Sourcepub fn subscribe(&self) -> Receiver<ProgressEvent>
pub fn subscribe(&self) -> Receiver<ProgressEvent>
订阅进度更新
Sourcepub fn snapshot(&self) -> ProgressEvent
pub fn snapshot(&self) -> ProgressEvent
获取当前快照
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ProgressTracker
impl !RefUnwindSafe for ProgressTracker
impl Send for ProgressTracker
impl Sync for ProgressTracker
impl Unpin for ProgressTracker
impl UnwindSafe for ProgressTracker
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