[−][src]Struct holochain_json_api::json::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 OptionFrom
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 to_bytes(&self) -> Vec<u8>
[src]
achieves the same outcome as serde_json::to_vec()
pub fn from_json(s: &str) -> JsonString
[src]
Trait Implementations
impl Clone for JsonString
[src]
fn clone(&self) -> JsonString
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for JsonString
[src]
impl<'de> Deserialize<'de> for JsonString
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for JsonString
[src]
impl Eq for JsonString
[src]
impl<'a> From<&'a JsonError> for JsonString
[src]
fn from(v: &JsonError) -> JsonString
[src]
impl<'a> From<&'a JsonString> for &'a str
[src]
fn from(json_string: &'a JsonString) -> &'a str
[src]
impl<'a> From<&'a JsonString> for String
[src]
fn from(json_string: &JsonString) -> String
[src]
impl From<&'static str> for JsonString
[src]
fn from(s: &str) -> JsonString
[src]
impl From<()> for JsonString
[src]
impl From<JsonError> for JsonString
[src]
fn from(v: JsonError) -> JsonString
[src]
impl From<JsonString> for String
[src]
fn from(json_string: JsonString) -> String
[src]
impl From<Option<String>> for JsonString
[src]
fn from(o: Option<String>) -> JsonString
[src]
impl<T> From<Option<T>> for JsonString where
T: Debug + Serialize + Into<JsonString>,
[src]
T: Debug + Serialize + Into<JsonString>,
fn from(o: Option<T>) -> JsonString
[src]
impl From<RawString> for JsonString
[src]
it should always be possible to Jsonify RawString, if not something is very wrong
fn from(raw_string: RawString) -> JsonString
[src]
impl<E> From<Result<String, E>> for JsonString where
E: Into<JsonString>,
[src]
E: Into<JsonString>,
fn from(result: Result<String, E>) -> JsonString
[src]
impl From<Result<String, String>> for JsonString
[src]
impl<T, E> From<Result<T, E>> for JsonString where
T: Into<JsonString>,
E: Into<JsonString>,
[src]
T: Into<JsonString>,
E: Into<JsonString>,
fn from(result: Result<T, E>) -> JsonString
[src]
impl<T> From<Result<T, String>> for JsonString where
T: Into<JsonString>,
[src]
T: Into<JsonString>,
fn from(result: Result<T, String>) -> JsonString
[src]
impl From<Value> for JsonString
[src]
fn from(v: Value) -> JsonString
[src]
impl<T: Serialize> From<Vec<T>> for JsonString
[src]
fn from(vector: Vec<T>) -> JsonString
[src]
impl From<bool> for JsonString
[src]
fn from(u: bool) -> JsonString
[src]
impl From<i32> for JsonString
[src]
fn from(u: i32) -> JsonString
[src]
impl From<u128> for JsonString
[src]
fn from(u: u128) -> JsonString
[src]
impl From<u32> for JsonString
[src]
fn from(u: u32) -> JsonString
[src]
impl From<u64> for JsonString
[src]
fn from(u: u64) -> JsonString
[src]
impl Hash for JsonString
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<JsonString> for JsonString
[src]
fn eq(&self, other: &JsonString) -> bool
[src]
fn ne(&self, other: &JsonString) -> bool
[src]
impl Serialize for JsonString
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
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.
fn try_from(json_string: &JsonString) -> Result<Self, Self::Error>
[src]
impl TryFrom<JsonString> for JsonError
[src]
type Error = JsonError
The type returned in the event of a conversion error.
fn try_from(json_string: JsonString) -> Result<Self, Self::Error>
[src]
impl TryFrom<JsonString> for bool
[src]
type Error = JsonError
The type returned in the event of a conversion error.
fn try_from(j: JsonString) -> Result<Self, Self::Error>
[src]
impl TryFrom<JsonString> for u32
[src]
type Error = JsonError
The type returned in the event of a conversion error.
fn try_from(j: JsonString) -> Result<Self, Self::Error>
[src]
impl TryFrom<JsonString> for u64
[src]
type Error = JsonError
The type returned in the event of a conversion error.
fn try_from(j: JsonString) -> Result<Self, Self::Error>
[src]
impl TryFrom<JsonString> for ()
[src]
type Error = JsonError
The type returned in the event of a conversion error.
fn try_from(j: JsonString) -> Result<Self, Self::Error>
[src]
impl TryFrom<JsonString> for RawString
[src]
converting a JsonString to RawString can fail if the JsonString is not a serialized string
type Error = JsonError
The type returned in the event of a conversion error.
fn try_from(j: JsonString) -> JsonResult<Self>
[src]
impl TryInto<JsonStringOption<String>> for JsonString
[src]
type Error = JsonError
The type returned in the event of a conversion error.
fn try_into(self) -> Result<JsonStringOption<String>, Self::Error>
[src]
impl<T> TryInto<JsonStringOption<T>> for JsonString where
T: Into<JsonString> + DeserializeOwned,
[src]
T: Into<JsonString> + DeserializeOwned,
type Error = JsonError
The type returned in the event of a conversion error.
fn try_into(self) -> Result<JsonStringOption<T>, Self::Error>
[src]
impl<E> TryInto<Result<String, E>> for JsonString where
E: Into<JsonString> + DeserializeOwned,
[src]
E: Into<JsonString> + DeserializeOwned,
type Error = JsonError
The type returned in the event of a conversion error.
fn try_into(self) -> Result<Result<String, E>, Self::Error>
[src]
impl TryInto<Result<String, String>> for JsonString
[src]
type Error = JsonError
The type returned in the event of a conversion error.
fn try_into(self) -> Result<Result<String, String>, Self::Error>
[src]
impl<T, E> TryInto<Result<T, E>> for JsonString where
T: Into<JsonString> + DeserializeOwned,
E: Into<JsonString> + DeserializeOwned,
[src]
T: Into<JsonString> + DeserializeOwned,
E: Into<JsonString> + DeserializeOwned,
type Error = JsonError
The type returned in the event of a conversion error.
fn try_into(self) -> Result<Result<T, E>, Self::Error>
[src]
impl<T> TryInto<Result<T, String>> for JsonString where
T: Into<JsonString> + DeserializeOwned,
[src]
T: Into<JsonString> + DeserializeOwned,
Auto Trait Implementations
impl RefUnwindSafe for JsonString
impl Send for JsonString
impl Sync for JsonString
impl Unpin for JsonString
impl UnwindSafe for JsonString
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> Clone for T where
T: Clone,
[src]
T: Clone,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[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> Same<T> for T
type Output = T
Should always be Self
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,