Struct Settings
pub struct Settings<T> { /* private fields */ }Expand description
An app’s typed settings of one SettingsSchema type, in the settings
document its host gave it. Get one from
HostContext::settings,
AppStorage::settings, or a framework view’s cx.settings::<T>().
Implementations§
§impl<T> Settings<T>where
T: SettingsSchema,
impl<T> Settings<T>where
T: SettingsSchema,
pub fn for_app(app_id: &str) -> Settings<T>
pub fn for_app(app_id: &str) -> Settings<T>
The settings of the app with this id, in the session document.
A Scope::Shared section, for code that serves every app (the
toolkit’s text fields reading text_assistance).
pub fn in_document(self, document: SettingsDocument) -> Settings<T>
pub fn in_document(self, document: SettingsDocument) -> Settings<T>
The same settings in document instead.
pub fn in_file(self, path: impl Into<PathBuf>) -> Settings<T>
pub fn in_file(self, path: impl Into<PathBuf>) -> Settings<T>
The same settings in the document file at path instead.
pub fn document(&self) -> &SettingsDocument
pub fn document(&self) -> &SettingsDocument
The document they live in.
pub fn get(&self) -> T
pub fn get(&self) -> T
The current value.
pub fn set(&self, value: &T) -> Result<(), Error>
pub fn set(&self, value: &T) -> Result<(), Error>
Store value. Keys of the section that T does not name are kept.
§Errors
When value does not serialize to an object, a personal section
would outgrow what the device fabric carries, there is no document to
write, or the write fails.
pub fn revision(&self) -> SettingsRevision
pub fn revision(&self) -> SettingsRevision
The document’s current version: when it changes, Self::get may
answer differently.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Settings<T>
impl<T> RefUnwindSafe for Settings<T>
impl<T> Send for Settings<T>
impl<T> Sync for Settings<T>
impl<T> Unpin for Settings<T>
impl<T> UnsafeUnpin for Settings<T>
impl<T> UnwindSafe for Settings<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more