3 use std
::cmp
::Ordering
;
5 use endian_trait
::Endian
;
8 /// ACL permission bits.
10 pub struct Permissions
: u64 {
11 const PXAR_ACL_PERMISSION_READ
= 4;
12 const PXAR_ACL_PERMISSION_WRITE
= 2;
13 const PXAR_ACL_PERMISSION_EXECUTE
= 1;
17 #[derive(Clone, Debug, Endian, Eq)]
21 pub permissions
: Permissions
,
22 //pub name: Vec<u64>, not impl for now
25 // TODO if also name is impl, sort by uid, then by name and last by permissions
27 fn cmp(&self, other
: &User
) -> Ordering
{
28 match self.uid
.cmp(&other
.uid
) {
29 // uids are equal, entries ordered by permissions
30 Ordering
::Equal
=> self.permissions
.cmp(&other
.permissions
),
31 // uids are different, entries ordered by uid
32 uid_order
=> uid_order
,
37 impl PartialOrd
for User
{
38 fn partial_cmp(&self, other
: &User
) -> Option
<Ordering
> {
43 impl PartialEq
for User
{
44 fn eq(&self, other
: &User
) -> bool
{
45 self.uid
== other
.uid
&& self.permissions
== other
.permissions
49 #[derive(Clone, Debug, Endian, Eq)]
53 pub permissions
: Permissions
,
54 //pub name: Vec<u64>, not impl for now
57 // TODO if also name is impl, sort by gid, then by name and last by permissions
59 fn cmp(&self, other
: &Group
) -> Ordering
{
60 match self.gid
.cmp(&other
.gid
) {
61 // gids are equal, entries are ordered by permissions
62 Ordering
::Equal
=> self.permissions
.cmp(&other
.permissions
),
63 // gids are different, entries ordered by gid
64 gid_ordering
=> gid_ordering
,
69 impl PartialOrd
for Group
{
70 fn partial_cmp(&self, other
: &Group
) -> Option
<Ordering
> {
75 impl PartialEq
for Group
{
76 fn eq(&self, other
: &Group
) -> bool
{
77 self.gid
== other
.gid
&& self.permissions
== other
.permissions
81 #[derive(Clone, Debug, Endian)]
83 pub struct GroupObject
{
84 pub permissions
: Permissions
,
87 #[derive(Clone, Debug, Endian)]
90 pub user_obj_permissions
: Permissions
,
91 pub group_obj_permissions
: Permissions
,
92 pub other_permissions
: Permissions
,
93 pub mask_permissions
: Permissions
,