Skip to main content

Settings

Struct Settings 

Source
pub struct Settings { /* private fields */ }
Expand description

typed settings over a file (see the module header)

Implementations§

Source§

impl Settings

Source

pub fn open(path: &str, schema: &'static Schema) -> Settings

the settings of a file (a missing or unreadable file: the defaults)

Source

pub fn new(schema: &'static Schema) -> Settings

settings only in memory (save does nothing)

Source

pub fn from_ini(ini: Ini, schema: &'static Schema) -> Settings

settings in memory, read from an Ini (migrated like a file)

Source

pub fn schema(&self) -> &'static Schema

Source

pub fn path(&self) -> &str

the file’s path (“” in memory)

Source

pub fn file_version(&self) -> u32

the format version the file had before a migration (0: none / no version line)

Source

pub fn get<T: Value>(&self, k: &Key<T>) -> T

a value (the key’s default when the key is not in the schema and not in the file)

Source

pub fn text(&self, k: &Key<String>) -> &str

a text without copying it

Source

pub fn set<T: Value>(&mut self, k: &Key<T>, v: T) -> bool

set a value (made valid for the key) -> it changed

Source

pub fn reset<T>(&mut self, k: &Key<T>) -> bool

back to the default (the line leaves the file)

Source

pub fn reset_all(&mut self) -> bool

every key of the schema back to its default

Source

pub fn is_default<T>(&self, k: &Key<T>) -> bool

the key has its default value

Source

pub fn at(&self, i: usize) -> &Val

the value of schema key i

Source

pub fn default_at(&self, i: usize) -> Val

the default of schema key i

Source

pub fn set_at(&mut self, i: usize, v: Val) -> bool

set schema key i (made valid) -> it changed

Source

pub fn dirty(&self) -> bool

unsaved changes

Source

pub fn revision(&self) -> u32

counts every change (redraw or apply what depends on the settings when it moved)

Source

pub fn ini(&self) -> &Ini

the file’s data (free-form sections the schema does not describe)

Source

pub fn ini_mut(&mut self) -> &mut Ini

change free-form data (marks the settings dirty; keys of the schema: use set)

Source

pub fn save(&mut self) -> bool

write the file when something changed (atomic; in memory: nothing) -> ok

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.