1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub struct Inode(pub(in crate::pristine) u64);
impl std::fmt::Debug for Inode {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
use byteorder::{ByteOrder, LittleEndian};
let mut b = [0; 8];
LittleEndian::write_u64(&mut b, self.0);
write!(fmt, "Inode({})", data_encoding::BASE32_NOPAD.encode(&b))
}
}
impl Inode {
pub const ROOT: Inode = Inode(0);
pub fn is_root(&self) -> bool {
*self == Inode::ROOT
}
pub(crate) fn random() -> Self {
Inode(rand::random())
}
}