Trait ToJson

Source
pub trait ToJson: Serialize {
    // Provided methods
    fn to_json_writer(&self, writer: impl Write, pretty: bool) -> Result<()> { ... }
    fn to_json_vec(&self, pretty: bool) -> Result<Vec<u8>> { ... }
}
Expand description

Writes a STAC object to JSON bytes.

Provided Methods§

Source

fn to_json_writer(&self, writer: impl Write, pretty: bool) -> Result<()>

Writes a value as JSON.

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

let mut buf = Vec::new();
Item::new("an-id").to_json_writer(&mut buf, true).unwrap();
Source

fn to_json_vec(&self, pretty: bool) -> Result<Vec<u8>>

Writes a value as JSON bytes.

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

Item::new("an-id").to_json_vec(true).unwrap();

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.

Implementors§

Source§

impl<T: Serialize> ToJson for T