[−][src]Trait savefile::Introspect
Gives the ability to look into an object, inspecting any children (fields).
Required methods
fn introspect_value(&self) -> String
Returns the value of the object, excluding children, as a string. Exactly what the value returned here is depends on the type. For some types, like a plain array, there isn't much of a value, the entire information of object resides in the children. For other cases, like a department in an organisation, it might make sense to have the value be the name, and have all the other properties as children.
fn introspect_child<'a>(
&'a self,
index: usize
) -> Option<Box<dyn IntrospectItem<'a> + 'a>>
&'a self,
index: usize
) -> Option<Box<dyn IntrospectItem<'a> + 'a>>
Returns an the name and &dyn Introspect for the child with the given index, or if no child with that index exists, None. All the children should be indexed consecutively starting at 0 with no gaps, all though there isn't really anything stopping the user of the trait to have any arbitrary index strategy, consecutive numbering 0, 1, 2, ... etc is strongly encouraged.
Provided methods
fn introspect_len(&self) -> usize
Returns the total number of children. The default implementation calculates this by simply calling introspect_child with higher and higher indexes until it returns None. It gives up if the count reaches 10000. If your type can be bigger and you want to be able to introspect it, override this method.
Implementations on Foreign Types
impl Introspect for String
[src]
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, _index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
impl<T: Introspect> Introspect for Mutex<T>
[src]
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
impl<T: Introspect> Introspect for Arc<T>
[src]
default fn introspect_value(&self) -> String
[src]
default fn introspect_child(
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
[src]
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
default fn introspect_len(&self) -> usize
[src]
impl<T: Introspect> Introspect for RwLock<T>
[src]
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
fn introspect_len(&self) -> usize
[src]
impl<K: Introspect + Eq + Hash, V: Introspect, S: BuildHasher> Introspect for HashMap<K, V, S>
[src]
default fn introspect_value(&self) -> String
[src]
default fn introspect_child(
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
[src]
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
default fn introspect_len(&self) -> usize
[src]
impl<K: Introspect + Eq + Hash, S: BuildHasher> Introspect for HashSet<K, S>
[src]
default fn introspect_value(&self) -> String
[src]
default fn introspect_child(
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
[src]
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
default fn introspect_len(&self) -> usize
[src]
impl<K: Introspect + Eq + Hash, V: Introspect, S: BuildHasher> Introspect for HashMap<K, V, S> where
K: ToString,
[src]
K: ToString,
default fn introspect_value(&self) -> String
[src]
default fn introspect_child(
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
[src]
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
default fn introspect_len(&self) -> usize
[src]
impl<K: Introspect + Eq + Hash, V: Introspect, S: BuildHasher> Introspect for IndexMap<K, V, S>
[src]
default fn introspect_value(&self) -> String
[src]
default fn introspect_child(
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
[src]
&self,
index: usize
) -> Option<Box<dyn IntrospectItem>>
default fn introspect_len(&self) -> usize
[src]
impl<K: Introspect + Eq + Hash, V: Introspect, S: BuildHasher> Introspect for IndexMap<K, V, S> where
K: ToString,
[src]
K: ToString,
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
fn introspect_len(&self) -> usize
[src]
impl<K: Introspect + Eq + Hash, S: BuildHasher> Introspect for IndexSet<K, S>
[src]
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
fn introspect_len(&self) -> usize
[src]
impl<T> Introspect for PhantomData<T>
[src]
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, _index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
impl<T: Introspect> Introspect for Box<T>
[src]
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
fn introspect_len(&self) -> usize
[src]
impl<T: Introspect> Introspect for Option<T>
[src]
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
fn introspect_len(&self) -> usize
[src]
impl Introspect for BitVec
[src]
fn introspect_value(&self) -> String
[src]
fn introspect_child(&self, _index: usize) -> Option<Box<dyn IntrospectItem>>
[src]
impl<T: Array> Introspect for SmallVec<T> where
T::Item: Introspect,
[src]
T::Item: Introspect,