Skip to main content

PermissionsExt

Trait PermissionsExt 

Source
pub trait PermissionsExt: Sealed {
    // Required methods
    fn file_attributes(&self) -> u32;
    fn set_file_attributes(&mut self, mask: u32);
    fn from_file_attributes(mask: u32) -> Self;
}
🔬This is a nightly-only experimental API. (windows_permissions_ext #152956)
Available on Windows only.
Expand description

Windows-specific extensions to fs::Permissions. This extension trait provides extra utilities to shows what Windows file attributes are enabled in Permissions and to manually set file attributes on Permissions.

See Microsoft’s File Attribute Constants page to know what file attribute metadata are defined and stored on Windows files.

§Example

#![feature(windows_permissions_ext)]
use std::fs::Permissions;
use std::os::windows::fs::PermissionsExt;

const FILE_ATTRIBUTE_SYSTEM: u32 = 0x4;
const FILE_ATTRIBUTE_ARCHIVE: u32 = 0x20;
let my_file_attr = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE;
let mut permissions = Permissions::from_file_attributes(my_file_attr);
assert_eq!(permissions.file_attributes(), my_file_attr);

const FILE_ATTRIBUTE_HIDDEN: u32 = 0x2;
let new_file_attr = permissions.file_attributes() | FILE_ATTRIBUTE_HIDDEN;
permissions.set_file_attributes(new_file_attr);
assert_eq!(permissions.file_attributes(), new_file_attr);

Required Methods§

Source

fn file_attributes(&self) -> u32

🔬This is a nightly-only experimental API. (windows_permissions_ext #152956)

Returns the file attribute bits.

Source

fn set_file_attributes(&mut self, mask: u32)

🔬This is a nightly-only experimental API. (windows_permissions_ext #152956)

Sets the file attribute bits.

Source

fn from_file_attributes(mask: u32) -> Self

🔬This is a nightly-only experimental API. (windows_permissions_ext #152956)

Creates a new instance from the given file attribute bits.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§