Trait json_syntax::TryFromJson

source ·
pub trait TryFromJson: Sized {
    type Error;

    // Required method
    fn try_from_json_at(
        value: &Value,
        code_map: &CodeMap,
        offset: usize,
    ) -> Result<Self, Self::Error>;

    // Provided method
    fn try_from_json(
        value: &Value,
        code_map: &CodeMap,
    ) -> Result<Self, Self::Error> { ... }
}
Expand description

Conversion from JSON syntax, with code mapping info.

This trait is very similar to TryFrom<Value> but also passes code code mapping info to the conversion function.

Required Associated Types§

source

type Error

Error that may be returned by the conversion function.

Required Methods§

source

fn try_from_json_at( value: &Value, code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

Tries to convert the given JSON value into Self, using the given code_map and the offset of value in the code map.

Note to implementors: use the JsonArray::iter_mapped and Object::iter_mapped methods to visit arrays and objects while keeping track of the code map offset of each visited item.

Provided Methods§

source

fn try_from_json(value: &Value, code_map: &CodeMap) -> Result<Self, Self::Error>

Tries to convert the given JSON value into Self, using the given code_map.

It is assumed that the offset of value in the code map is 0, for instance if it is the output of a Parse trait function.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl TryFromJson for bool

§

type Error = Mapped<Unexpected>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for f32

§

type Error = Mapped<TryIntoNumberError<NumberType<f32>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for f64

§

type Error = Mapped<TryIntoNumberError<NumberType<f64>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for i8

§

type Error = Mapped<TryIntoNumberError<NumberType<i8>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for i16

§

type Error = Mapped<TryIntoNumberError<NumberType<i16>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for i32

§

type Error = Mapped<TryIntoNumberError<NumberType<i32>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for i64

§

type Error = Mapped<TryIntoNumberError<NumberType<i64>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for isize

§

type Error = Mapped<TryIntoNumberError<NumberType<isize>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for u8

§

type Error = Mapped<TryIntoNumberError<NumberType<u8>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for u16

§

type Error = Mapped<TryIntoNumberError<NumberType<u16>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for u32

§

type Error = Mapped<TryIntoNumberError<NumberType<u32>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for u64

§

type Error = Mapped<TryIntoNumberError<NumberType<u64>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for ()

§

type Error = Mapped<Unexpected>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for usize

§

type Error = Mapped<TryIntoNumberError<NumberType<usize>>>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl TryFromJson for String

§

type Error = Mapped<Unexpected>

source§

fn try_from_json_at( json: &Value, _code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl<K: FromStr + Ord, V: TryFromJson> TryFromJson for BTreeMap<K, V>
where V::Error: From<Mapped<Unexpected>> + From<Mapped<K::Err>>,

§

type Error = <V as TryFromJson>::Error

source§

fn try_from_json_at( json: &Value, code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl<T: TryFromJson> TryFromJson for Option<T>

§

type Error = <T as TryFromJson>::Error

source§

fn try_from_json_at( json: &Value, code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl<T: TryFromJson> TryFromJson for Box<T>

§

type Error = <T as TryFromJson>::Error

source§

fn try_from_json_at( json: &Value, code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

source§

impl<T: TryFromJson> TryFromJson for Vec<T>

§

type Error = <T as TryFromJson>::Error

source§

fn try_from_json_at( json: &Value, code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

Implementors§