Skip to main content

rusty_spotted_cat/
ids.rs

1use std::fmt;
2
3use uuid::Uuid;
4
5/// 由 [`crate::MeowClient::enqueue`] 返回,用于后续暂停、取消等操作关联同一传输任务。
6#[derive(Clone, Copy, PartialEq, Eq, Hash)]
7pub struct TaskId(Uuid);
8
9impl TaskId {
10    pub(crate) fn new_v4() -> Self {
11        Self(Uuid::new_v4())
12    }
13}
14
15impl fmt::Debug for TaskId {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        fmt::Debug::fmt(&self.0, f)
18    }
19}
20
21/// 通过 [`crate::MeowClient::register_global_progress_listener`] 注册后返回,用于 [`crate::MeowClient::unregister_global_progress_listener`]。
22#[derive(Clone, Copy, PartialEq, Eq, Hash)]
23pub struct GlobalProgressListenerId(Uuid);
24
25impl GlobalProgressListenerId {
26    pub(crate) fn new_v4() -> Self {
27        Self(Uuid::new_v4())
28    }
29}
30
31impl fmt::Debug for GlobalProgressListenerId {
32    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33        fmt::Debug::fmt(&self.0, f)
34    }
35}