Trait rsfs::Permissions
[−]
[src]
pub trait Permissions: Clone + PartialEq + Eq + Debug { fn readonly(&self) -> bool; fn set_readonly(&mut self, readonly: bool); }
Representation of the various permissions on a file.
This trait only requires readonly
and set_readonly
, which are the only two "cross
platform" functions provided in std::fs
. However, the unix_ext
module has a useful
PermissionsExt
trait to complement this one.
Required Methods
fn readonly(&self) -> bool
Returns whether these permissions have readonly set.
Examples
use rsfs::*; use rsfs::mem::FS; let fs = FS::new(); let file = fs.create_file("foo.txt")?; let metadata = file.metadata()?; assert_eq!(false, metadata.permissions().readonly());
fn set_readonly(&mut self, readonly: bool)
Modifies the readonly fly for these permissions.
This does not modify the filesystem. To modify the filesystem, use the filesystem's
set_permissions
function.
Examples
use rsfs::*; use rsfs::mem::FS; let fs = FS::new(); let file = fs.create_file("foo.txt")?; let metadata = file.metadata()?; let mut permissions = metadata.permissions(); permissions.set_readonly(true); // filesystem doesn't change assert_eq!(false, metadata.permissions().readonly()); // just this particular `permissions`. assert_eq!(true, permissions.readonly());
Implementors
impl Permissions for rsfs::disk::Permissions
impl Permissions for rsfs::mem::Permissions
impl Permissions for rsfs::mem::unix::Permissions