Trait IQ

Source
pub trait IQ {
    // Required methods
    fn extract_primitive<P: IqPath>(&self, path: P) -> Option<String>;
    fn extract_json<P: IqPath>(&self, path: P) -> Option<String>;
    fn extract_json_pretty<P: IqPath>(&self, path: P) -> Option<String>;
    fn extract_value<P: IqPath, V: DeserializeOwned>(
        &self,
        path: P,
    ) -> Result<Option<V>, IqError>;
    fn extract_size<P: IqPath>(&self, path: P) -> Option<usize>;
}
Expand description

A trait to import if you want extract function on any Serialize type.

Required Methods§

Source

fn extract_primitive<P: IqPath>(&self, path: P) -> Option<String>

Extract a “primitive” value (including strings, simple enum variants, etc) as a string using the Display implementation of the deep value.

Source

fn extract_json<P: IqPath>(&self, path: P) -> Option<String>

Extract a value as JSON

Source

fn extract_json_pretty<P: IqPath>(&self, path: P) -> Option<String>

Extract a value as JSON, pretty

Source

fn extract_value<P: IqPath, V: DeserializeOwned>( &self, path: P, ) -> Result<Option<V>, IqError>

Extract a value in a type which must implement Deserialize, from a value, at the given path.

This function uses a JSON representation of the deep value as intermediate step, which adds some (usually light) overload but also allows to extract in a different type than the real type of the deep value.

Source

fn extract_size<P: IqPath>(&self, path: P) -> Option<usize>

Extract the size of the string/tuple/map/vec/struct at the given path

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> IQ for T
where T: Serialize,