pub struct OpenFlags {
pub read: bool,
pub write: bool,
pub create: bool,
pub truncate: bool,
pub append: bool,
}Expand description
Flags for opening a file.
Controls how a file is opened: read/write mode, creation behavior, and
truncation. Used with FsHandles::open.
§Predefined Constants
| Constant | Behavior |
|---|---|
OpenFlags::READ | Read-only access |
OpenFlags::WRITE | Write with create and truncate |
OpenFlags::READ_WRITE | Read and write, file must exist |
OpenFlags::APPEND | Append mode (writes go to end) |
§Fields
| Field | Effect |
|---|---|
read | Enable reading from file |
write | Enable writing to file |
create | Create file if it doesn’t exist |
truncate | Truncate file to zero length on open |
append | Writes always go to end of file |
§Example
use anyfs_backend::OpenFlags;
// Use predefined constants
let read_only = OpenFlags::READ;
assert!(read_only.read);
assert!(!read_only.write);
// Custom flags
let custom = OpenFlags {
read: true,
write: true,
create: true,
truncate: false,
append: false,
};Fields§
§read: boolOpen for reading.
write: boolOpen for writing.
create: boolCreate file if it doesn’t exist.
truncate: boolTruncate file to zero length.
append: boolAppend to end of file.
Implementations§
Trait Implementations§
impl Copy for OpenFlags
Auto Trait Implementations§
impl Freeze for OpenFlags
impl RefUnwindSafe for OpenFlags
impl Send for OpenFlags
impl Sync for OpenFlags
impl Unpin for OpenFlags
impl UnwindSafe for OpenFlags
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more