[][src]Trait feattle_core::FeattleValue

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

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

fn as_json(&self) -> Value

Convert the value to its JSON representation.

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.

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

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

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.

Loading content...

Implementations on Foreign Types

impl FeattleValue for bool[src]

impl FeattleValue for u8[src]

impl FeattleValue for i8[src]

impl FeattleValue for u16[src]

impl FeattleValue for i16[src]

impl FeattleValue for u32[src]

impl FeattleValue for i32[src]

impl FeattleValue for u64[src]

impl FeattleValue for i64[src]

impl FeattleValue for u128[src]

impl FeattleValue for i128[src]

impl FeattleValue for usize[src]

impl FeattleValue for isize[src]

impl FeattleValue for f32[src]

impl FeattleValue for f64[src]

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

impl<T: FeattleValue + Ord> FeattleValue for BTreeSet<T>[src]

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

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

Loading content...

Implementors

impl<T> FeattleValue for T where
    T: FeattleStringValue,
    <T as FromStr>::Err: Error + Send + Sync + 'static, 
[src]

Loading content...