Trait savefile::Introspect[][src]

pub trait Introspect {
    fn introspect_value(&self) -> String;
fn introspect_child<'a>(
        &'a self,
        index: usize
    ) -> Option<Box<dyn IntrospectItem<'a> + 'a>>; fn introspect_len(&self) -> usize { ... } }
Expand description

Gives the ability to look into an object, inspecting any children (fields).

Required methods

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.

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

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

Implementors