[][src]Struct b3_rs::Item

pub struct Item {
    pub key: ItemKey,
    pub value: ItemValue,
}

A singular item.

Fields

key: ItemKeyvalue: 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]

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

impl<T> BorrowMut<T> for T where
    T: ?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, 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.