[][src]Struct holochain_wasmer_common::JsonString

pub struct JsonString(_);

track json serialization with the rust type system! JsonString wraps a string containing JSON serialized data avoid accidental double-serialization or forgetting to serialize serialize any type consistently including hard-to-reach places like Option and Result JsonString must not itself be serialized/deserialized instead, implement and use the native From trait to move between types

  • moving to/from String, str, JsonString and JsonString simply (un)wraps it as raw JSON data
  • moving to/from any other type must offer a reliable serialization/deserialization strategy

Methods

impl JsonString[src]

pub fn null() -> JsonString[src]

a null JSON value e.g. represents None when implementing From<Option>

pub fn empty_object() -> JsonString[src]

pub fn is_null(&self) -> bool[src]

pub fn from_json(s: &str) -> JsonString[src]

pub fn to_bytes(&self) -> Vec<u8>[src]

achieves the same outcome as serde_json::to_vec()

pub fn from_bytes(bytes: Vec<u8>) -> JsonString[src]

Trait Implementations

impl Clone for JsonString[src]

impl Debug for JsonString[src]

impl<'de> Deserialize<'de> for JsonString[src]

impl Display for JsonString[src]

impl Eq for JsonString[src]

impl<'a> From<&'a JsonError> for JsonString[src]

impl<'a> From<&'a WasmError> for JsonString[src]

impl<'a> From<&'a WasmResult> for JsonString[src]

impl From<&'static str> for JsonString[src]

impl From<()> for JsonString[src]

impl From<JsonError> for JsonString[src]

impl From<Option<String>> for JsonString[src]

impl<T> From<Option<T>> for JsonString where
    T: Debug + Serialize + Into<JsonString>, 
[src]

impl From<RawString> for JsonString[src]

it should always be possible to Jsonify RawString, if not something is very wrong

impl<E> From<Result<String, E>> for JsonString where
    E: Into<JsonString>, 
[src]

impl From<Result<String, String>> for JsonString[src]

impl<T, E> From<Result<T, E>> for JsonString where
    E: Into<JsonString>,
    T: Into<JsonString>, 
[src]

impl<T> From<Result<T, String>> for JsonString where
    T: Into<JsonString>, 
[src]

impl From<Value> for JsonString[src]

impl<T> From<Vec<T>> for JsonString where
    T: Serialize
[src]

impl From<WasmError> for JsonString[src]

impl From<WasmResult> for JsonString[src]

impl From<bool> for JsonString[src]

impl From<i32> for JsonString[src]

impl From<u128> for JsonString[src]

impl From<u32> for JsonString[src]

impl From<u64> for JsonString[src]

impl Hash for JsonString[src]

impl PartialEq<JsonString> for JsonString[src]

impl Serialize for JsonString[src]

impl StructuralEq for JsonString[src]

impl StructuralPartialEq for JsonString[src]

impl<'a> TryFrom<&'a JsonString> for JsonError[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a JsonString> for WasmError[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a JsonString> for WasmResult[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl TryFrom<JsonString> for JsonError[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl TryFrom<JsonString> for WasmError[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl TryFrom<JsonString> for WasmResult[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl TryInto<JsonStringOption<String>> for JsonString[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl<T> TryInto<JsonStringOption<T>> for JsonString where
    T: Into<JsonString> + DeserializeOwned
[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl<E> TryInto<Result<String, E>> for JsonString where
    E: Into<JsonString> + DeserializeOwned
[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl TryInto<Result<String, String>> for JsonString[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl<T, E> TryInto<Result<T, E>> for JsonString where
    E: Into<JsonString> + DeserializeOwned,
    T: Into<JsonString> + DeserializeOwned
[src]

type Error = JsonError

The type returned in the event of a conversion error.

impl<T> TryInto<Result<T, String>> for JsonString where
    T: Into<JsonString> + DeserializeOwned
[src]

type Error = JsonError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.