[−][src]Struct b3_rs::Item
A singular item.
Fields
key: ItemKey
value: ItemValue
Implementations
impl Item
[src]
pub fn new(key: ItemKey, value: ItemValue) -> Self
[src]
Create a new item with the given key and value.
pub fn with_key(self, key: ItemKey) -> Self
[src]
Add a key to the item, returning the item. Useful for chaining.
let item = Item::from("value").with_key(ItemKey::from("key"));
pub fn encode(&self) -> Result<Vec<u8>, Error>
[src]
Encode this item into it's byte representation.
Internally this calls the encode()
method on the ItemValue
,
constructs an ItemHeader
based on the output from that, encodes
that header, and stitches the two together.
pub fn decode(input: &[u8]) -> Result<(Item, usize), Error>
[src]
Decodes an item from the given byte input.
If the item is a container type (CompositeList
or CompositeDict
),
the item is decoded recursively.
If decoding was successful, returns the item, and the number of bytes consumed by this decode operation.
Trait Implementations
impl Clone for Item
[src]
impl Debug for Item
[src]
impl<'_> From<&'_ [u8]> for Item
[src]
impl<'_> From<&'_ str> for Item
[src]
impl From<String> for Item
[src]
impl From<Vec<u8>> for Item
[src]
impl From<bool> for Item
[src]
impl From<f64> for Item
[src]
impl From<i32> for Item
[src]
impl From<i64> for Item
[src]
impl From<u32> for Item
[src]
impl From<u64> for Item
[src]
impl PartialEq<Item> for Item
[src]
impl StructuralPartialEq for Item
[src]
Auto Trait Implementations
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnwindSafe for Item
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>,