[−][src]Struct in_toto::interchange::JsonPretty
Pretty JSON data interchange.
This is identical to Json in all manners except for the to_writer
method. Instead of
writing the metadata in the canonical format, it instead pretty prints the metadata.
Trait Implementations
impl Clone for JsonPretty
[src]
fn clone(&self) -> JsonPretty
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl DataInterchange for JsonPretty
[src]
type RawData = Value
The type of data that is contained in the signed
portion of metadata.
fn extension() -> &'static str
[src]
assert_eq!(JsonPretty::extension(), "json");
fn canonicalize(raw_data: &Self::RawData) -> Result<Vec<u8>>
[src]
let jsn: &[u8] = br#"{"foo": "bar", "baz": "quux"}"#; let raw = JsonPretty::from_reader(jsn).unwrap(); let out = JsonPretty::canonicalize(&raw).unwrap(); assert_eq!(out, br#"{"baz":"quux","foo":"bar"}"#);
fn deserialize<T>(raw_data: &Self::RawData) -> Result<T> where
T: DeserializeOwned,
[src]
T: DeserializeOwned,
#[derive(Deserialize, Debug, PartialEq)] struct Thing { foo: String, bar: String, } let jsn = json!({"foo": "wat", "bar": "lol"}); let thing = Thing { foo: "wat".into(), bar: "lol".into() }; let de: Thing = JsonPretty::deserialize(&jsn).unwrap(); assert_eq!(de, thing);
fn serialize<T>(data: &T) -> Result<Self::RawData> where
T: Serialize,
[src]
T: Serialize,
#[derive(Serialize)] struct Thing { foo: String, bar: String, } let jsn = json!({"foo": "wat", "bar": "lol"}); let thing = Thing { foo: "wat".into(), bar: "lol".into() }; let se: serde_json::Value = JsonPretty::serialize(&thing).unwrap(); assert_eq!(se, jsn);
fn to_writer<W, T: Sized>(writer: W, value: &T) -> Result<()> where
W: Write,
T: Serialize,
[src]
W: Write,
T: Serialize,
let json = json!({ "o": { "a": [1, 2, 3], "s": "string", "n": 123, "t": true, "f": false, "0": null, }, }); let mut buf = Vec::new(); JsonPretty::to_writer(&mut buf, &json).unwrap(); assert_eq!(&String::from_utf8(buf).unwrap(), r#"{ "o": { "0": null, "a": [ 1, 2, 3 ], "f": false, "n": 123, "s": "string", "t": true } }"#);
fn from_reader<R, T>(rdr: R) -> Result<T> where
R: Read,
T: DeserializeOwned,
[src]
R: Read,
T: DeserializeOwned,
let jsn: &[u8] = br#"{"foo": "bar", "baz": "quux"}"#; let _: HashMap<String, String> = JsonPretty::from_reader(jsn).unwrap();
fn from_slice<T>(slice: &[u8]) -> Result<T> where
T: DeserializeOwned,
[src]
T: DeserializeOwned,
let jsn: &[u8] = br#"{"foo": "bar", "baz": "quux"}"#; let _: HashMap<String, String> = JsonPretty::from_slice(&jsn).unwrap();
impl Debug for JsonPretty
[src]
impl PartialEq<JsonPretty> for JsonPretty
[src]
impl StructuralPartialEq for JsonPretty
[src]
Auto Trait Implementations
impl RefUnwindSafe for JsonPretty
impl Send for JsonPretty
impl Sync for JsonPretty
impl Unpin for JsonPretty
impl UnwindSafe for JsonPretty
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,