Trait json_syntax::TryFromJsonObject

source ·
pub trait TryFromJsonObject: Sized {
    type Error;

    // Required method
    fn try_from_json_object_at(
        object: &Object,
        code_map: &CodeMap,
        offset: usize,
    ) -> Result<Self, Self::Error>;

    // Provided method
    fn try_from_json_object(
        object: &Object,
        code_map: &CodeMap,
    ) -> Result<Self, Self::Error> { ... }
}
Expand description

Conversion from JSON syntax object, with code mapping info.

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

Required Associated Types§

Required Methods§

source

fn try_from_json_object_at( object: &Object, code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

Tries to convert the given JSON object into Self, using the given code_map and the offset of object 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_object( object: &Object, code_map: &CodeMap, ) -> Result<Self, Self::Error>

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

It is assumed that the offset of object 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<T: TryFromJsonObject> TryFromJsonObject for Box<T>

§

type Error = <T as TryFromJsonObject>::Error

source§

fn try_from_json_object_at( object: &Object, code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>

Implementors§