Enum libipld_macro::Ipld [−][src]
pub enum Ipld {
Null,
Bool(bool),
Integer(i128),
Float(f64),
String(String),
Bytes(Vec<u8, Global>),
List(Vec<Ipld, Global>),
StringMap(BTreeMap<String, Ipld>),
Link(Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>),
}Expand description
Construct an Ipld from a literal.
let value = ipld!({ "code": 200, "success": true, "payload": { "features": [ "serde", "json" ] } });
Variables or expressions can be interpolated into the JSON literal. Any type
interpolated into an array element or object value must implement Serde’s
Serialize trait, while any type interpolated into a object key must
implement Into<String>. If the Serialize implementation of the
interpolated type decides to fail, or if the interpolated type contains a
map with non-string keys, the json! macro will panic.
let code = 200; let features = vec!["serde", "json"]; let value = ipld!({ "code": code, "success": code == 200, "payload": { features[0]: features[1] } });
Trailing commas are allowed inside both arrays and objects.
let value = ipld!([ "notice", "the", "trailing", "comma -->", ]);
Ipld
Variants
Represents the absence of a value or the value undefined.
Bool(bool)Represents a boolean value.
Integer(i128)Represents an integer.
Float(f64)Represents a floating point value.
String(String)Represents an UTF-8 string.
Represents a sequence of bytes.
Represents a list.
Represents a map of strings.
Represents a link to an Ipld node.
Implementations
impl Ipld[src]
impl Ipld[src]Construct an Ipld from a literal.
let value = ipld!({ "code": 200, "success": true, "payload": { "features": [ "serde", "json" ] } });
Variables or expressions can be interpolated into the JSON literal. Any type
interpolated into an array element or object value must implement Serde’s
Serialize trait, while any type interpolated into a object key must
implement Into<String>. If the Serialize implementation of the
interpolated type decides to fail, or if the interpolated type contains a
map with non-string keys, the json! macro will panic.
let code = 200; let features = vec!["serde", "json"]; let value = ipld!({ "code": code, "success": code == 200, "payload": { features[0]: features[1] } });
Trailing commas are allowed inside both arrays and objects.
let value = ipld!([ "notice", "the", "trailing", "comma -->", ]);
pub fn take<'a, T>(self, index: T) -> Result<Ipld, TypeError> where
T: Into<IpldIndex<'a>>, [src]
pub fn take<'a, T>(self, index: T) -> Result<Ipld, TypeError> where
T: Into<IpldIndex<'a>>, [src]Destructs an ipld list or map
pub fn get<'a, T>(&self, index: T) -> Result<&Ipld, TypeError> where
T: Into<IpldIndex<'a>>, [src]
pub fn get<'a, T>(&self, index: T) -> Result<&Ipld, TypeError> where
T: Into<IpldIndex<'a>>, [src]Indexes into an ipld list or map.
pub fn references<E>(&self, set: &mut E) where
E: Extend<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>, [src]
pub fn references<E>(&self, set: &mut E) where
E: Extend<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>, [src]Returns the references to other blocks.
Trait Implementations
impl<'_> From<&'_ Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Ipld[src]
impl<'_> From<&'_ Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Ipld[src]impl From<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Ipld[src]
impl From<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Ipld[src]impl StructuralPartialEq for Ipld[src]
Auto Trait Implementations
impl RefUnwindSafe for Ipld
impl Send for Ipld
impl Sync for Ipld
impl Unpin for Ipld
impl UnwindSafe for Ipld
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> References<RawCodec> for T[src]
impl<T> References<RawCodec> for T[src]impl<T> Same<T> for T
impl<T> Same<T> for Ttype Output = T
type Output = TShould always be Self
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more