[][src]Trait savefile::Introspect

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 { ... } }

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>>

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.

Loading content...

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.

Loading content...

Implementations on Foreign Types

impl Introspect for String[src]

impl<T: Introspect> Introspect for Mutex<T>[src]

impl<T: Introspect> Introspect for Arc<T>[src]

impl<T: Introspect> Introspect for RwLock<T>[src]

impl<K: Introspect + Eq + Hash, V: Introspect, S: BuildHasher> Introspect for HashMap<K, V, S>[src]

impl<K: Introspect + Eq + Hash, S: BuildHasher> Introspect for HashSet<K, S>[src]

impl<K: Introspect + Eq + Hash, V: Introspect, S: BuildHasher> Introspect for HashMap<K, V, S> where
    K: ToString
[src]

impl<K: Introspect + Eq + Hash, V: Introspect, S: BuildHasher> Introspect for IndexMap<K, V, S>[src]

impl<K: Introspect + Eq + Hash, V: Introspect, S: BuildHasher> Introspect for IndexMap<K, V, S> where
    K: ToString
[src]

impl<K: Introspect + Eq + Hash, S: BuildHasher> Introspect for IndexSet<K, S>[src]

impl<T> Introspect for PhantomData<T>[src]

impl<T: Introspect> Introspect for Box<T>[src]

impl<T: Introspect> Introspect for Option<T>[src]

impl Introspect for BitVec[src]

impl<T: Array> Introspect for SmallVec<T> where
    T::Item: Introspect
[src]

impl<T: Introspect> Introspect for Vec<T>[src]

impl<T: Introspect> Introspect for VecDeque<T>[src]

impl<T: Introspect, const N: usize> Introspect for [T; N][src]

impl Introspect for ()[src]

impl<T: Introspect> Introspect for (T,)[src]

impl<T1: Introspect, T2: Introspect> Introspect for (T1, T2)[src]

impl<T1: Introspect, T2: Introspect, T3: Introspect> Introspect for (T1, T2, T3)[src]

impl<T1: Introspect, T2: Introspect, T3: Introspect, T4: Introspect> Introspect for (T1, T2, T3, T4)[src]

impl Introspect for AtomicBool[src]

impl Introspect for AtomicU8[src]

impl Introspect for AtomicI8[src]

impl Introspect for AtomicU16[src]

impl Introspect for AtomicI16[src]

impl Introspect for AtomicU32[src]

impl Introspect for AtomicI32[src]

impl Introspect for AtomicU64[src]

impl Introspect for AtomicI64[src]

impl Introspect for AtomicUsize[src]

impl Introspect for AtomicIsize[src]

impl Introspect for bool[src]

impl Introspect for u8[src]

impl Introspect for u16[src]

impl Introspect for u32[src]

impl Introspect for u64[src]

impl Introspect for u128[src]

impl Introspect for i8[src]

impl Introspect for i16[src]

impl Introspect for i32[src]

impl Introspect for i64[src]

impl Introspect for i128[src]

impl Introspect for f32[src]

impl Introspect for f64[src]

impl Introspect for usize[src]

impl Introspect for isize[src]

Loading content...

Implementors

impl Introspect for Canary1[src]

impl<T: Introspect> Introspect for Removed<T>[src]

Loading content...