Trait stac::FromJson

source ·
pub trait FromJson: DeserializeOwned + Href {
    // Provided methods
    fn from_json_path(path: impl AsRef<Path>) -> Result<Self> { ... }
    fn from_json_slice(slice: &[u8]) -> Result<Self> { ... }
}
Expand description

Create a STAC object from JSON.

Provided Methods§

source

fn from_json_path(path: impl AsRef<Path>) -> Result<Self>

Reads JSON data from a file.

§Examples
use stac::{FromJson, Item};

let item = Item::from_json_path("examples/simple-item.json").unwrap();
source

fn from_json_slice(slice: &[u8]) -> Result<Self>

Creates an object from JSON bytes.

§Examples
use std::{fs::File, io::Read};
use stac::{Item, FromJson};

let mut buf = Vec::new();
File::open("examples/simple-item.json").unwrap().read_to_end(&mut buf).unwrap();
let item = Item::from_json_slice(&buf).unwrap();

Object Safety§

This trait is not object safe.

Implementors§