Struct fyrox_core::visitor::RegionGuard

source ·
pub struct RegionGuard<'a>(/* private fields */);
Expand description

A RegionGuard is a Visitor that automatically leaves the current region when it is dropped.

Methods from Deref<Target = Visitor>§

source

pub const MAGIC: &'static str = "RG3D"

source

pub fn is_reading(&self) -> bool

True if this Visitor is changing the values that it visits. In other words x.visit("MyValue", &mut visitor) will result in x being mutated to match whatever value is stored in visitor.

False if this visitor is copying and storing the values that it visits. In other words x.visit("MyValue", &mut visitor) will result in x being unchanged, but visitor will be mutated to store the value of x under the name “MyValue”.

source

pub fn enter_region( &mut self, name: &str ) -> Result<RegionGuard<'_>, VisitError>

If Visitor::is_reading, find a node with the given name that is a child of the current node, and return a Visitor for the found node. Return an error if no node with that name exists.

If not reading, create a node with the given name as a chld of the current node, and return a visitor for the new node. Return an error if a node with that name already exists.

source

pub fn current_region(&self) -> Option<&str>

The name of the current region. This should never be None if the Visitor is operating normally, because there should be no way to leave the initial __ROOT__ region.

source

pub fn save_text(&self) -> String

Create a String containing all the data of this Visitor. The String is formatted to be human-readable with each node on its own line and tabs to indent child nodes.

source

pub fn save_binary_to_memory<W: Write>(&self, writer: W) -> VisitResult

Write the data of this Visitor to the given writer. Begin by writing Visitor::MAGIC.

source

pub fn save_binary_to_vec(&self) -> Result<Vec<u8>, VisitError>

Encode the data of this visitor into bytes and push the bytes into the given Vec<u8>. Begin by writing Visitor::MAGIC.

source

pub fn save_binary<P: AsRef<Path>>(&self, path: P) -> VisitResult

Create a file at the given path and write the data of this visitor into that file in a non-human-readable binary format so that the data can be reconstructed using Visitor::load_binary. Begin by writing Visitor::MAGIC.

Trait Implementations§

source§

impl<'a> DerefMut for RegionGuard<'a>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a> Drop for RegionGuard<'a>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a> Deref for RegionGuard<'a>

§

type Target = Visitor

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> Freeze for RegionGuard<'a>

§

impl<'a> !RefUnwindSafe for RegionGuard<'a>

§

impl<'a> !Send for RegionGuard<'a>

§

impl<'a> !Sync for RegionGuard<'a>

§

impl<'a> Unpin for RegionGuard<'a>

§

impl<'a> !UnwindSafe for RegionGuard<'a>

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> FieldValue for T
where T: 'static,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
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> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V