-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathinode.rs
More file actions
23 lines (20 loc) · 676 Bytes
/
inode.rs
File metadata and controls
23 lines (20 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use derive_more::{Display, From, Into, LowerHex, Octal, UpperHex};
#[cfg(feature = "json")]
use serde::{Deserialize, Serialize};
/// The inode number of a file or directory.
#[derive(
Debug, Display, Clone, Copy, PartialEq, Eq, Hash, From, Into, LowerHex, UpperHex, Octal,
)]
#[cfg_attr(feature = "json", derive(Deserialize, Serialize))]
pub struct InodeNumber(u64);
/// POSIX-exclusive functions.
#[cfg(unix)]
impl InodeNumber {
/// Get inode number of a [`std::fs::Metadata`].
#[inline]
pub fn get(stats: &std::fs::Metadata) -> Self {
use pipe_trait::Pipe;
use std::os::unix::fs::MetadataExt;
stats.ino().pipe(InodeNumber)
}
}