Skip to main content

rusty_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
21impl fmt::Display for TaskId {
22    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23        fmt::Display::fmt(&self.0, f)
24    }
25}
26
27/// 通过 [`crate::MeowClient::register_global_progress_listener`] 注册后返回,用于 [`crate::MeowClient::unregister_global_progress_listener`]。
28#[derive(Clone, Copy, PartialEq, Eq, Hash)]
29pub struct GlobalProgressListenerId(Uuid);
30
31impl GlobalProgressListenerId {
32    pub(crate) fn new_v4() -> Self {
33        Self(Uuid::new_v4())
34    }
35}
36
37impl fmt::Debug for GlobalProgressListenerId {
38    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39        fmt::Debug::fmt(&self.0, f)
40    }
41}