rust_extra/
UnixFileSystemPermissionMode.rs

1// This file is part of dpdk. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/dpdk/master/COPYRIGHT. No part of dpdk, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2016 The developers of dpdk. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/dpdk/master/COPYRIGHT.
3
4
5#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub struct UnixFileSystemPermissionMode
7{
8	pub mode: u32
9}
10
11impl UnixFileSystemPermissionMode
12{
13	#[inline(always)]
14	pub fn fromMetadata(metadata: &Metadata) -> Self
15	{
16		Self::fromPermissions(&metadata.permissions())
17	}
18	
19	#[cfg(unix)]
20	#[inline(always)]
21	pub fn fromPermissions(permissions: &Permissions) -> Self
22	{
23		UnixFileSystemPermissionMode
24		{
25			mode: permissions.mode()
26		}
27	}
28	
29	#[inline(always)]
30	pub fn isOwnerExecutable(&self) -> bool
31	{
32		self.mode & 0o0100 == 0o0100
33	}
34	
35	#[inline(always)]
36	pub fn isGroupExecutable(&self) -> bool
37	{
38		self.mode & 0o0010 == 0o0010
39	}
40	
41	#[inline(always)]
42	pub fn isOtherExecutable(&self) -> bool
43	{
44		self.mode & 0o0001 == 0o0001
45	}
46	
47	#[inline(always)]
48	pub fn isOwnerReadableAndExecutable(&self) -> bool
49	{
50		self.mode & 0o0500 == 0o0500
51	}
52	
53	#[inline(always)]
54	pub fn isAllExecutable(&self) -> bool
55	{
56		self.mode & 0o0111 == 0o0111
57	}
58	
59	#[inline(always)]
60	pub fn isAllWritable(&self) -> bool
61	{
62		self.mode & 0o0222 == 0o0222
63	}
64	
65	#[inline(always)]
66	pub fn isAllReadable(&self) -> bool
67	{
68		self.mode & 0o0444 == 0o0444
69	}
70}