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