pub type Stage = u32;
mod mode;
pub use mode::Mode;
mod flags;
pub(crate) use flags::at_rest;
pub use flags::Flags;
mod write;
#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Time {
pub secs: u32,
pub nsecs: u32,
}
#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Stat {
pub mtime: Time,
pub ctime: Time,
pub dev: u32,
pub ino: u32,
pub uid: u32,
pub gid: u32,
pub size: u32,
}
mod access {
use bstr::{BStr, ByteSlice};
use crate::{entry, Entry, State};
impl Entry {
pub fn path<'a>(&self, state: &'a State) -> &'a BStr {
(&state.path_backing[self.path.clone()]).as_bstr()
}
pub fn path_in<'backing>(&self, backing: &'backing crate::PathStorageRef) -> &'backing BStr {
(backing[self.path.clone()]).as_bstr()
}
pub fn stage(&self) -> entry::Stage {
self.flags.stage()
}
}
}
mod _impls {
use std::cmp::Ordering;
use crate::{Entry, State};
impl Entry {
pub fn cmp(&self, other: &Self, state: &State) -> Ordering {
let lhs = self.path(state);
let rhs = other.path(state);
let common_len = lhs.len().min(rhs.len());
lhs[..common_len]
.cmp(&rhs[..common_len])
.then_with(|| lhs.len().cmp(&rhs.len()))
.then_with(|| self.stage().cmp(&other.stage()))
}
}
}