Trait bevy_reflect::GetPath
source · pub trait GetPath {
fn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r dyn Reflect, ReflectPathError<'p>>;
fn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut dyn Reflect, ReflectPathError<'p>>;
fn get_path<'r, 'p, T: Reflect>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>> { ... }
fn get_path_mut<'r, 'p, T: Reflect>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>> { ... }
}
Expand description
A trait which allows nested values to be retrieved with path strings.
Path strings use Rust syntax:
Struct
items are accessed with a dot and a field name:.field_name
TupleStruct
andTuple
items are accessed with a dot and a number:.0
List
items 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, ReflectPathError<'p>>
fn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r dyn Reflect, 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, ReflectPathError<'p>>
fn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut dyn Reflect, 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<'r, 'p, T: Reflect>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>
fn get_path<'r, 'p, T: Reflect>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>
Returns a statically typed reference to the value specified by path
.
sourcefn get_path_mut<'r, 'p, T: Reflect>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>
fn get_path_mut<'r, 'p, T: Reflect>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>
Returns a statically typed mutable reference to the value specified by
path
.