Public dry run dryrun-3744910a2d27
Source commit: 3744910a2d27b833e906fc28d8960cdd457f166c Public tree identity: sha256:5459dfd2bb2b9c89f78dbb3a04655ec811249a44fd04e4e49d884c0d24b01dcf
This commit is contained in:
commit
7c9fedb8ae
112 changed files with 38585 additions and 0 deletions
44
crates/disasmer-core/src/ids.rs
Normal file
44
crates/disasmer-core/src/ids.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
macro_rules! id_type {
|
||||
($name:ident) => {
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct $name(String);
|
||||
|
||||
impl $name {
|
||||
pub fn new(value: impl Into<String>) -> Self {
|
||||
let value = value.into();
|
||||
assert!(
|
||||
!value.trim().is_empty(),
|
||||
concat!(stringify!($name), " cannot be empty")
|
||||
);
|
||||
Self(value)
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for $name {
|
||||
fn from(value: &str) -> Self {
|
||||
Self::new(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for $name {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(&self.0)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
id_type!(AgentId);
|
||||
id_type!(ArtifactId);
|
||||
id_type!(NodeId);
|
||||
id_type!(ProcessId);
|
||||
id_type!(ProjectId);
|
||||
id_type!(TaskId);
|
||||
id_type!(TenantId);
|
||||
id_type!(UserId);
|
||||
Loading…
Add table
Add a link
Reference in a new issue