dope_sys/io/file/
metadata.rs1use std::num::NonZero;
2
3use crate::io::file::Kind;
4
5#[derive(Clone, Copy, Debug, Eq, PartialEq)]
6pub struct Identity {
7 pub device: u64,
8 pub inode: u64,
9}
10
11#[derive(Clone, Copy, Debug, Eq, PartialEq)]
12pub enum Error {
13 Missing(NonZero<u32>),
14 Negative(i64),
15 Overflow(u64),
16}
17
18#[derive(Clone, Copy, Debug)]
20pub struct Metadata {
21 kind: Kind,
22 size: i64,
23 identity: Identity,
24}
25
26impl Metadata {
27 pub(super) const fn new(raw: &libc::stat) -> Self {
28 Self {
29 kind: Kind::from_mode(raw.st_mode),
30 size: raw.st_size,
31 identity: Identity {
32 device: raw.st_dev as _,
33 inode: raw.st_ino as _,
34 },
35 }
36 }
37
38 pub const fn kind(self) -> Kind {
39 self.kind
40 }
41
42 pub const fn size(self) -> i64 {
44 self.size
45 }
46
47 pub const fn identity(self) -> Identity {
48 self.identity
49 }
50}