[]Struct holochain_wasmer_guest::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

pub fn null() -> JsonString

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

pub fn empty_object() -> JsonString

pub fn is_null(&self) -> bool

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

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

achieves the same outcome as serde_json::to_vec()

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

Trait Implementations

impl Clone for JsonString

impl Debug for JsonString

impl<'de> Deserialize<'de> for JsonString

impl Display for JsonString

impl Eq for JsonString

impl<'a> From<&'a JsonError> for JsonString

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

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

impl From<&'static str> for JsonString

impl From<()> for JsonString

impl From<JsonError> for JsonString

impl From<Option<String>> for JsonString

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

impl From<RawString> for JsonString

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>, 

impl From<Result<String, String>> for JsonString

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

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

impl From<Value> for JsonString

impl<T> From<Vec<T>> for JsonString where
    T: Serialize

impl From<WasmError> for JsonString[src]

impl From<WasmResult> for JsonString[src]

impl From<bool> for JsonString

impl From<i32> for JsonString

impl From<u128> for JsonString

impl From<u32> for JsonString

impl From<u64> for JsonString

impl Hash for JsonString

impl PartialEq<JsonString> for JsonString

impl Serialize for JsonString

impl StructuralEq for JsonString

impl StructuralPartialEq for JsonString

impl<'a> TryFrom<&'a JsonString> for WasmResult[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 JsonError

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 TryFrom<JsonString> for JsonError

type Error = JsonError

The type returned in the event of a conversion error.

impl TryInto<JsonStringOption<String>> for JsonString

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

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

type Error = JsonError

The type returned in the event of a conversion error.

impl TryInto<Result<String, String>> for JsonString

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

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

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.