Trait feattle::FeattleValue

source ·
pub trait FeattleValue: Debug + Sized {
    // Required methods
    fn as_json(&self) -> Value;
    fn overview(&self) -> String;
    fn try_from_json(value: &Value) -> Result<Self, FromJsonError>;
    fn serialized_format() -> SerializedFormat;
}
Expand description

The base trait for types that can be used for feattles.

This lib already implements this trait for many base types from the std lib, but the user can make their own types compatible by providing their own logic.

For types that are string based, it suffices to implement the somewhat simpler FeattleStringValue trait.

Required Methods§

source

fn as_json(&self) -> Value

Convert the value to its JSON representation.

source

fn overview(&self) -> String

Return a short overview of the current value. This is meant to give an overall idea of the actual value. For example, it can choose to display only the first 3 items of a large list.

source

fn try_from_json(value: &Value) -> Result<Self, FromJsonError>

Parse from a JSON representation of the value, if possible.

source

fn serialized_format() -> SerializedFormat

Return a precise description of a feattle type. This will be consumed, for example, by the UI code to show an appropriate HTML form in the admin panel.

Implementations on Foreign Types§

source§

impl<T> FeattleValue for BTreeSet<T, Global>where T: FeattleValue + Ord,

source§

impl FeattleValue for f32

source§

impl FeattleValue for u32

source§

impl FeattleValue for f64

source§

impl FeattleValue for u64

source§

impl FeattleValue for i8

source§

impl<K, V> FeattleValue for BTreeMap<K, V, Global>where K: FeattleStringValue + Ord, V: FeattleValue, <K as FromStr>::Err: Error + Send + Sync + 'static,

source§

impl FeattleValue for i16

source§

impl FeattleValue for i32

source§

impl FeattleValue for usize

source§

impl FeattleValue for u8

source§

impl FeattleValue for u16

source§

impl FeattleValue for i64

source§

impl<T> FeattleValue for Option<T>where T: FeattleValue,

source§

impl FeattleValue for isize

source§

impl FeattleValue for bool

source§

impl<T> FeattleValue for Vec<T, Global>where T: FeattleValue,

Implementors§

source§

impl<T> FeattleValue for Twhere T: FeattleStringValue, <T as FromStr>::Err: Error + Send + Sync + 'static,