Trait bevy_internal::reflect::GetPath
source · pub trait GetPath {
fn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>;
fn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>;
fn get_path<T, 'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>
where
T: Reflect,
{ ... }
fn get_path_mut<T, 'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>
where
T: Reflect,
{ ... }
}Expand description
A trait which allows nested values to be retrieved with path strings.
Path strings use Rust syntax:
Structitems are accessed with a dot and a field name:.field_nameTupleStructandTupleitems are accessed with a dot and a number:.0Listitems are accessed with brackets:[0]
If the initial path element is a field of a struct, tuple struct, or tuple, the initial ‘.’ may be omitted.
For example, given a struct with a field foo which is a reflected list of
2-tuples (like a Vec<(T, U)>), the path string foo[3].0 would access tuple
element 0 of element 3 of foo.
Required Methods§
sourcefn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
fn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
Returns a reference to the value specified by path.
To retrieve a statically typed reference, use
get_path.
sourcefn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
Returns a mutable reference to the value specified by path.
To retrieve a statically typed mutable reference, use
get_path_mut.
Provided Methods§
sourcefn get_path<T, 'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>where
T: Reflect,
fn get_path<T, 'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>where
T: Reflect,
Returns a statically typed reference to the value specified by path.
sourcefn get_path_mut<T, 'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>where
T: Reflect,
fn get_path_mut<T, 'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>where
T: Reflect,
Returns a statically typed mutable reference to the value specified by
path.