pub struct Layers { /* private fields */ }Expand description
The layers above app, by path.
Implementations§
Source§impl Layers
impl Layers
pub fn new() -> Layers
Sourcepub fn declare(&mut self, scope: ValueScope)
pub fn declare(&mut self, scope: ValueScope)
Declares a host scope above those declared before it (it wins over
them); declaring it again changes nothing. app and run are not
declared.
Sourcepub fn declared(&self) -> &[ValueScope]
pub fn declared(&self) -> &[ValueScope]
The host’s scopes, lowest first.
Sourcepub fn stack(&self) -> Vec<ValueScope>
pub fn stack(&self) -> Vec<ValueScope>
Every scope, lowest first: app, the host’s, run.
Sourcepub fn offer(&mut self, scope: ValueScope, on: bool)
pub fn offer(&mut self, scope: ValueScope, on: bool)
Offers a host scope for editing (the application opened its library, its workspace…), or takes it back. A scope not declared yet is declared, above the others.
Sourcepub fn offered(&self) -> &[ValueScope]
pub fn offered(&self) -> &[ValueScope]
The editable layers open, lowest first.
Sourcepub fn origin(&self, path: &str) -> ValueScope
pub fn origin(&self, path: &str) -> ValueScope
The layer the effective value comes from: the highest holding the
path, else app.
Sourcepub fn holders(
&self,
path: &str,
store: &Json,
default: &Json,
) -> Vec<ValueScope>
pub fn holders( &self, path: &str, store: &Json, default: &Json, ) -> Vec<ValueScope>
The scopes holding a value for the path, lowest first (app when
it differs from the default, as store and default say).
Sourcepub fn value_in(
&self,
scope: ValueScope,
path: &str,
store: &Json,
) -> Option<Json>
pub fn value_in( &self, scope: ValueScope, path: &str, store: &Json, ) -> Option<Json>
A layer’s own value for the path; app’s is the store’s unless a
layer above holds the path.
Sourcepub fn app_value(&self, path: &str, store: &Json) -> Json
pub fn app_value(&self, path: &str, store: &Json) -> Json
The app value: the one kept aside, else the store’s.
Sourcepub fn set(
&mut self,
scope: ValueScope,
path: &str,
value: Json,
store: &Json,
) -> Option<Json>
pub fn set( &mut self, scope: ValueScope, path: &str, value: Json, store: &Json, ) -> Option<Json>
Sets a value in a layer. store is the store’s value now. Returns
the effective value when it changes (the caller writes it).
None for run (set with Layers::set_run).
Sourcepub fn set_run(&mut self, path: &str, value: Json, store: &Json) -> Option<Json>
pub fn set_run(&mut self, path: &str, value: Json, store: &Json) -> Option<Json>
The command line’s override of a path.
Sourcepub fn clear(
&mut self,
scope: ValueScope,
path: &str,
store: &Json,
default: &Json,
) -> Option<Json>
pub fn clear( &mut self, scope: ValueScope, path: &str, store: &Json, default: &Json, ) -> Option<Json>
Takes a layer’s value back (its reset): app goes back to the
default. Returns the effective value when it changes.
Sourcepub fn export(&self, scope: ValueScope) -> BTreeMap<String, Json>
pub fn export(&self, scope: ValueScope) -> BTreeMap<String, Json>
A layer’s values (what the application saves with its library or workspace).
Sourcepub fn load(
&mut self,
scope: ValueScope,
values: BTreeMap<String, Json>,
store: &dyn Fn(&str) -> Option<Json>,
) -> Vec<(String, Json)>
pub fn load( &mut self, scope: ValueScope, values: BTreeMap<String, Json>, store: &dyn Fn(&str) -> Option<Json>, ) -> Vec<(String, Json)>
Replaces a layer’s values (a library or workspace opened, or
closed with an empty map). store reads the store’s value of a
path. Returns the effective values to write.