file_system/fundamentals/
statistics.rs

1use users::{GroupIdentifier, UserIdentifier};
2
3use crate::{FileSystemIdentifier, Kind, Size, Time};
4
5use super::{Inode, Permissions};
6
7/// Statistics of a file.
8///
9/// This type contains information about a file, such as its size, inode, etc.
10///
11/// # Fields
12///
13/// * `File_system`: The file system the file is on.
14/// * `Inode`: The inode of the file.
15/// * `Links`: The number of hard links to the file.
16/// * `Size`: The size of the file.
17/// * `Last_access`: The last time the file was accessed.
18/// * `Last_modification`: The last time the file was modified.
19/// * `Last_status_change`: The last time the file's status was changed.
20/// * `Type`: The type of the file.
21#[derive(Debug, Clone, PartialEq, Eq)]
22#[repr(C)]
23pub struct Statistics_type {
24    file_system: FileSystemIdentifier,
25    group: GroupIdentifier,
26    inode: Inode,
27    last_access: Time,
28    last_modification: Time,
29    last_status_change: Time,
30    links: u64,
31    permissions: Permissions,
32    r#type: Kind,
33    size: Size,
34    user: UserIdentifier,
35}
36
37impl Statistics_type {
38    #[allow(clippy::too_many_arguments)]
39    pub fn new(
40        file_system: FileSystemIdentifier,
41        inode: Inode,
42        links: u64,
43        size: Size,
44        last_access: Time,
45        last_modification: Time,
46        last_status_change: Time,
47        type_value: Kind,
48        permissions: Permissions,
49        user: UserIdentifier,
50        group: GroupIdentifier,
51    ) -> Self {
52        Statistics_type {
53            file_system,
54            inode,
55            links,
56            size,
57            last_access,
58            last_modification,
59            last_status_change,
60            r#type: type_value,
61            permissions,
62            user,
63            group,
64        }
65    }
66
67    pub const fn get_file_system(&self) -> FileSystemIdentifier {
68        self.file_system
69    }
70
71    pub const fn get_inode(&self) -> Inode {
72        self.inode
73    }
74
75    pub const fn get_links(&self) -> u64 {
76        self.links
77    }
78
79    pub const fn get_size(&self) -> Size {
80        self.size
81    }
82
83    pub const fn get_last_access(&self) -> Time {
84        self.last_access
85    }
86
87    pub const fn get_last_modification(&self) -> Time {
88        self.last_modification
89    }
90
91    pub const fn get_last_status_change(&self) -> Time {
92        self.last_status_change
93    }
94
95    pub const fn get_type(&self) -> Kind {
96        self.r#type
97    }
98
99    pub const fn get_permissions(&self) -> Permissions {
100        self.permissions
101    }
102
103    pub const fn get_user(&self) -> UserIdentifier {
104        self.user
105    }
106
107    pub const fn get_group(&self) -> GroupIdentifier {
108        self.group
109    }
110
111    pub fn set_file_system(&mut self, file_system: FileSystemIdentifier) -> &mut Self {
112        self.file_system = file_system;
113        self
114    }
115
116    pub fn set_inode(&mut self, inode: Inode) -> &mut Self {
117        self.inode = inode;
118        self
119    }
120
121    pub fn set_type(&mut self, r#type: Kind) -> &mut Self {
122        self.r#type = r#type;
123        self
124    }
125
126    pub fn set_links(&mut self, links: u64) -> &mut Self {
127        self.links = links;
128        self
129    }
130
131    pub fn set_size(&mut self, size: Size) -> &mut Self {
132        self.size = size;
133        self
134    }
135
136    pub fn set_last_access(&mut self, last_access: Time) -> &mut Self {
137        self.last_access = last_access;
138        self
139    }
140
141    pub fn set_last_modification(&mut self, last_modification: Time) -> &mut Self {
142        self.last_modification = last_modification;
143        self
144    }
145
146    pub fn set_last_status_change(&mut self, last_status_change: Time) -> &mut Self {
147        self.last_status_change = last_status_change;
148        self
149    }
150
151    pub fn set_permissions(&mut self, permissions: Permissions) -> &mut Self {
152        self.permissions = permissions;
153        self
154    }
155
156    pub fn set_user(&mut self, user: UserIdentifier) -> &mut Self {
157        self.user = user;
158        self
159    }
160
161    pub fn set_group(&mut self, group: GroupIdentifier) -> &mut Self {
162        self.group = group;
163        self
164    }
165}