30 lines
886 B
Rust
30 lines
886 B
Rust
//! Small stable identity types shared across workspace layers.
|
|
|
|
use std::fmt;
|
|
|
|
macro_rules! digest_id {
|
|
($name:ident, $prefix:literal) => {
|
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
pub struct $name(pub [u8; 32]);
|
|
|
|
impl fmt::Debug for $name {
|
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(formatter, "{}", self)
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for $name {
|
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(formatter, concat!($prefix, ":blake3:"))?;
|
|
for byte in self.0 {
|
|
write!(formatter, "{byte:02x}")?;
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
digest_id!(SourceId, "runa-source:v1");
|
|
digest_id!(ImplementationId, "runa-implementation:v1");
|