Struct fltk::app::prefs::Preferences
source · pub struct Preferences { /* private fields */ }
Expand description
Provides methods to store user settings between application starts
Implementations§
source§impl Preferences
impl Preferences
sourcepub fn set_file_access(flags: FileAccess)
pub fn set_file_access(flags: FileAccess)
Set filesystem access
sourcepub fn file_access() -> FileAccess
pub fn file_access() -> FileAccess
Get filesystem access flags
sourcepub fn new(root: Root, vendor: &str, application: &str) -> Option<Self>
pub fn new(root: Root, vendor: &str, application: &str) -> Option<Self>
Create a new Preferences object
Examples found in repository?
examples/prefs.rs (line 4)
3 4 5 6 7 8 9 10 11 12 13 14
fn main() {
let mut prefs = Preferences::new(Root::USER_L, "myfltk.org", "tempapp").unwrap();
let mut opts = Preferences::new_group(&mut prefs, "Options").unwrap();
opts.set_int("winsize", 400).unwrap();
let size = opts.get_int("winsize").unwrap_or(300);
opts.set_str("wintitle", "Hello").unwrap();
let title = opts.get_str("wintitle").unwrap_or("My Window".to_string());
println!("{}", size);
println!("{}", title);
println!("{:?}", opts.name());
println!("{:?}", prefs.filename());
}
sourcepub fn new_group(parent: &mut Preferences, group: &str) -> Option<Self>
pub fn new_group(parent: &mut Preferences, group: &str) -> Option<Self>
Create a preferences object entry inside the group
Examples found in repository?
examples/prefs.rs (line 5)
3 4 5 6 7 8 9 10 11 12 13 14
fn main() {
let mut prefs = Preferences::new(Root::USER_L, "myfltk.org", "tempapp").unwrap();
let mut opts = Preferences::new_group(&mut prefs, "Options").unwrap();
opts.set_int("winsize", 400).unwrap();
let size = opts.get_int("winsize").unwrap_or(300);
opts.set_str("wintitle", "Hello").unwrap();
let title = opts.get_str("wintitle").unwrap_or("My Window".to_string());
println!("{}", size);
println!("{}", title);
println!("{:?}", opts.name());
println!("{:?}", prefs.filename());
}
sourcepub fn filename(&self) -> Result<(PathBuf, Root), FltkError>
pub fn filename(&self) -> Result<(PathBuf, Root), FltkError>
Get the filename
Examples found in repository?
examples/prefs.rs (line 13)
3 4 5 6 7 8 9 10 11 12 13 14
fn main() {
let mut prefs = Preferences::new(Root::USER_L, "myfltk.org", "tempapp").unwrap();
let mut opts = Preferences::new_group(&mut prefs, "Options").unwrap();
opts.set_int("winsize", 400).unwrap();
let size = opts.get_int("winsize").unwrap_or(300);
opts.set_str("wintitle", "Hello").unwrap();
let title = opts.get_str("wintitle").unwrap_or("My Window".to_string());
println!("{}", size);
println!("{}", title);
println!("{:?}", opts.name());
println!("{:?}", prefs.filename());
}
sourcepub fn get_userdata_path(&self) -> Result<PathBuf, FltkError>
pub fn get_userdata_path(&self) -> Result<PathBuf, FltkError>
Get the userdata path
sourcepub fn set_int(&mut self, entry: &str, val: i32) -> Result<(), FltkError>
pub fn set_int(&mut self, entry: &str, val: i32) -> Result<(), FltkError>
Set the value of an entry
Examples found in repository?
examples/prefs.rs (line 6)
3 4 5 6 7 8 9 10 11 12 13 14
fn main() {
let mut prefs = Preferences::new(Root::USER_L, "myfltk.org", "tempapp").unwrap();
let mut opts = Preferences::new_group(&mut prefs, "Options").unwrap();
opts.set_int("winsize", 400).unwrap();
let size = opts.get_int("winsize").unwrap_or(300);
opts.set_str("wintitle", "Hello").unwrap();
let title = opts.get_str("wintitle").unwrap_or("My Window".to_string());
println!("{}", size);
println!("{}", title);
println!("{:?}", opts.name());
println!("{:?}", prefs.filename());
}
sourcepub fn get_int(&mut self, entry: &str) -> Result<i32, FltkError>
pub fn get_int(&mut self, entry: &str) -> Result<i32, FltkError>
Get the value of an entry
Examples found in repository?
examples/prefs.rs (line 7)
3 4 5 6 7 8 9 10 11 12 13 14
fn main() {
let mut prefs = Preferences::new(Root::USER_L, "myfltk.org", "tempapp").unwrap();
let mut opts = Preferences::new_group(&mut prefs, "Options").unwrap();
opts.set_int("winsize", 400).unwrap();
let size = opts.get_int("winsize").unwrap_or(300);
opts.set_str("wintitle", "Hello").unwrap();
let title = opts.get_str("wintitle").unwrap_or("My Window".to_string());
println!("{}", size);
println!("{}", title);
println!("{:?}", opts.name());
println!("{:?}", prefs.filename());
}
sourcepub fn set_float(&mut self, entry: &str, val: f32) -> Result<(), FltkError>
pub fn set_float(&mut self, entry: &str, val: f32) -> Result<(), FltkError>
Set the value of an entry
sourcepub fn set_float_with_precision(
&mut self,
entry: &str,
val: f32,
precision: u16
) -> Result<(), FltkError>
pub fn set_float_with_precision( &mut self, entry: &str, val: f32, precision: u16 ) -> Result<(), FltkError>
Set the value of an entry
sourcepub fn set_double(&mut self, entry: &str, val: f64) -> Result<(), FltkError>
pub fn set_double(&mut self, entry: &str, val: f64) -> Result<(), FltkError>
Set the value of an entry
sourcepub fn set_double_with_precision(
&mut self,
entry: &str,
val: f64,
precision: u16
) -> Result<(), FltkError>
pub fn set_double_with_precision( &mut self, entry: &str, val: f64, precision: u16 ) -> Result<(), FltkError>
Set the value of an entry
sourcepub fn set_str(&mut self, entry: &str, val: &str) -> Result<(), FltkError>
pub fn set_str(&mut self, entry: &str, val: &str) -> Result<(), FltkError>
Set the value of an entry
Examples found in repository?
examples/prefs.rs (line 8)
3 4 5 6 7 8 9 10 11 12 13 14
fn main() {
let mut prefs = Preferences::new(Root::USER_L, "myfltk.org", "tempapp").unwrap();
let mut opts = Preferences::new_group(&mut prefs, "Options").unwrap();
opts.set_int("winsize", 400).unwrap();
let size = opts.get_int("winsize").unwrap_or(300);
opts.set_str("wintitle", "Hello").unwrap();
let title = opts.get_str("wintitle").unwrap_or("My Window".to_string());
println!("{}", size);
println!("{}", title);
println!("{:?}", opts.name());
println!("{:?}", prefs.filename());
}
sourcepub fn get_str(&mut self, entry: &str) -> Result<String, FltkError>
pub fn get_str(&mut self, entry: &str) -> Result<String, FltkError>
Get the value of an entry
Examples found in repository?
examples/prefs.rs (line 9)
3 4 5 6 7 8 9 10 11 12 13 14
fn main() {
let mut prefs = Preferences::new(Root::USER_L, "myfltk.org", "tempapp").unwrap();
let mut opts = Preferences::new_group(&mut prefs, "Options").unwrap();
opts.set_int("winsize", 400).unwrap();
let size = opts.get_int("winsize").unwrap_or(300);
opts.set_str("wintitle", "Hello").unwrap();
let title = opts.get_str("wintitle").unwrap_or("My Window".to_string());
println!("{}", size);
println!("{}", title);
println!("{:?}", opts.name());
println!("{:?}", prefs.filename());
}
sourcepub fn name(&mut self) -> Option<String>
pub fn name(&mut self) -> Option<String>
Return the pref’s name
Examples found in repository?
examples/prefs.rs (line 12)
3 4 5 6 7 8 9 10 11 12 13 14
fn main() {
let mut prefs = Preferences::new(Root::USER_L, "myfltk.org", "tempapp").unwrap();
let mut opts = Preferences::new_group(&mut prefs, "Options").unwrap();
opts.set_int("winsize", 400).unwrap();
let size = opts.get_int("winsize").unwrap_or(300);
opts.set_str("wintitle", "Hello").unwrap();
let title = opts.get_str("wintitle").unwrap_or("My Window".to_string());
println!("{}", size);
println!("{}", title);
println!("{:?}", opts.name());
println!("{:?}", prefs.filename());
}
sourcepub fn group_exists(&mut self, key: &str) -> bool
pub fn group_exists(&mut self, key: &str) -> bool
Check whether a group exists
sourcepub fn delete_all_groups(&mut self) -> Result<(), FltkError>
pub fn delete_all_groups(&mut self) -> Result<(), FltkError>
Delete all groups
sourcepub fn entry_exists(&mut self, key: &str) -> bool
pub fn entry_exists(&mut self, key: &str) -> bool
Check whether an entry exists
sourcepub fn delete_all_entries(&mut self) -> Result<(), FltkError>
pub fn delete_all_entries(&mut self) -> Result<(), FltkError>
Delete all entries
Trait Implementations§
source§impl Clone for Preferences
impl Clone for Preferences
source§impl Debug for Preferences
impl Debug for Preferences
Auto Trait Implementations§
impl RefUnwindSafe for Preferences
impl !Send for Preferences
impl !Sync for Preferences
impl Unpin for Preferences
impl UnwindSafe for Preferences
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