1use std::path::Path;
2use std::str::FromStr;
3
4#[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
6pub struct ArchiveId(String);
7
8impl Default for ArchiveId {
9 fn default() -> Self {
10 Self::new()
11 }
12}
13
14impl ArchiveId {
15 pub fn new() -> Self {
17 Self(nanoid::nanoid!())
18 }
19}
20
21impl AsRef<Path> for ArchiveId {
22 fn as_ref(&self) -> &Path {
23 self.0.as_ref()
24 }
25}
26
27impl std::fmt::Display for ArchiveId {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 self.0.fmt(f)
30 }
31}
32
33impl FromStr for ArchiveId {
34 type Err = <String as FromStr>::Err;
35
36 fn from_str(s: &str) -> Result<Self, Self::Err> {
37 Ok(Self(s.to_string()))
38 }
39}