pub struct CVarSaveContext(/* private fields */);Expand description
Provides a context for mutating a TOML document to save CVars to it.
§Example
let mut context = CVarSaveContext::blank();
// Let's save the world config to this.
context.save_world(&world);
// And serialize out the results so we can save it.
let file_contents = context.to_string();Implementations§
Source§impl CVarSaveContext
impl CVarSaveContext
Sourcepub fn from_document(doc: DocumentMut) -> Self
pub fn from_document(doc: DocumentMut) -> Self
Creates a new context with an existing document.
Sourcepub fn return_document(self) -> DocumentMut
pub fn return_document(self) -> DocumentMut
Returns the document used from the context, destroying the context.
Sourcepub fn save_cvar<T: CVarMeta>(&mut self, cvar: &T) -> Result<(), CVarError>
pub fn save_cvar<T: CVarMeta>(&mut self, cvar: &T) -> Result<(), CVarError>
Manually save an individual CVar to the document.
§Remarks
This does not check for the presence of CVarFlags::SAVED, and as such can be used to specially handle some CVars.
Sourcepub fn save_cvar_from_world<T: CVarMeta>(
&mut self,
world: &World,
) -> Result<(), CVarError>
pub fn save_cvar_from_world<T: CVarMeta>( &mut self, world: &World, ) -> Result<(), CVarError>
Manually save an individual CVar to the document, from the world.
§Remarks
This does not check for the presence of CVarFlags::SAVED, and as such can be used to specially handle some CVars.
Sourcepub fn save_world(&mut self, world: &World) -> Result<(), CVarError>
pub fn save_world(&mut self, world: &World) -> Result<(), CVarError>
Saves a world’s CVars to the document.
§Remarks
This obeys CVarFlags::SAVED and will not attempt to save CVars without it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CVarSaveContext
impl RefUnwindSafe for CVarSaveContext
impl Send for CVarSaveContext
impl Sync for CVarSaveContext
impl Unpin for CVarSaveContext
impl UnsafeUnpin for CVarSaveContext
impl UnwindSafe for CVarSaveContext
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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