#[derive(Debug, Clone)]
pub struct FileOpenOptions {
pub read: bool,
pub write: bool,
pub create: bool,
pub append: bool,
pub truncate: bool,
}
impl Default for FileOpenOptions {
fn default() -> Self {
Self {
read: true,
write: false,
create: false,
append: false,
truncate: false,
}
}
}
impl FileOpenOptions {
pub fn read_only() -> Self {
Self {
read: true,
write: false,
create: false,
append: false,
truncate: false,
}
}
pub fn write_only() -> Self {
Self {
read: false,
write: true,
create: true,
append: false,
truncate: true,
}
}
pub fn append_only() -> Self {
Self {
read: false,
write: true,
create: true,
append: true,
truncate: false,
}
}
pub fn read_write() -> Self {
Self {
read: true,
write: true,
create: true,
append: false,
truncate: false,
}
}
}