Trait 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.

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.

Implementations on Foreign Types§

Source§

impl<T: TryFromJsonObject> TryFromJsonObject for Box<T>

Source§

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§