Struct settingsfile::Settings

source ·
pub struct Settings<T>where
    T: Format + Clone,
{ /* private fields */ }

Implementations

Creates an empty Settings from a configuration

Loads the content of a File using the configuration. Doesn’t use a path or doesn’t infer the path from the config because this method is easier to do testing on to ensure everything behaves as expected

Wrapper around load_from so the return value isn’t an result. loads a new setting object from a path, or creates an empty object if file doesn’t exist or errors in any way.

loads from the file defined in ioconfig if nothing exists it throws an error. This shouldn’t be used for initalizing a new Settings, look at create and create_from for that.

loads into the current Setting with the buffer of the file

saves the setting to a file, uses the save_to buffer function

saves the setting to a file buffer. Maybe done this way because of ease of writing good tests?

normally you should always use get_value, as it properly splits the key_path to get the correct value in the tree. if you are working with a flattend Settings then get_value will not work as it will attempt to split the key and it will find nothing, this function will NEVER split the key

looks for a key_path in dot notation and returns an Option containing the value if it exists.

sets the value of a key, uses a generic that must implement the SupportedType trait

deletes the key and returns the current value, returns none if the key didn’t exist.

Trait Implementations

implementing add so you should be able to use ‘+’ on two settings, useful because you may want to combine settings from different locations.

Adding to Settings works by overlaying the two Settings on top of each other, if the same “key” has multiple “values”, the “self” is overwritten with the “other”. So Adding a Settings means you are overlaying it ontop of the existing data.

The resulting type after applying the + operator.

AddAssign follows the same logic as Add, and allows you to use += with Settings

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.