[][src]Enum b3_rs::ItemValue

pub enum ItemValue {
    Null,
    CompositeList(Vec<Item>),
    CompositeDict(Vec<Item>),
    Bytes(Vec<u8>),
    UTF8(String),
    Boolean(bool),
    Int64(i64),
    UVarInt(u64),
    SVarInt(i64),
    Float64(f64),
    Stamp64(i64),
    UnknownType(u64Vec<u8>),
}

The value of an item.

Variants

Null

A null value.

CompositeList(Vec<Item>)

A list containing multiple Items.

CompositeDict(Vec<Item>)

A list containing multiple Items, where the presence of an ItemKey on the objects contained within is guaranteed.

Bytes(Vec<u8>)

A byte array.

UTF8(String)

A UTF-8 string.

Boolean(bool)

A boolean.

Int64(i64)

A signed 64-bit integer.

UVarInt(u64)

An unsigned variable-length integer, represented as a u64.

SVarInt(i64)

A signed variable-length integer, represented as an i64.

Float64(f64)

A 64-bit floating point number.

Stamp64(i64)

A signed UNIX timestamp, represented as an i64.

UnknownType(u64Vec<u8>)

Arbitrary data of an unknown type.

This type's first value is the type number sent on the wire, and the second value is a byte array of the raw data sent in the message.

Implementations

impl ItemValue[src]

pub fn data_type(&self) -> DataType[src]

Returns the DataType of this value.

pub fn encode(&self) -> Result<(DataType, Vec<u8>), Error>[src]

Encodes this value into it's byte representation.

If encoding was successful, returns the data type of the encoded value, and a Vec<u8> of the bytes representing the value.

pub fn decode(header: &ItemHeader, data: &[u8]) -> Result<(Self, usize), Error>[src]

Decode the given data using the type and data length from the given ItemHeader.

If decoding succeeds, returns the decoded ItemValue, and the number of bytes consumed by this decode operation.

pub fn get_entries(&self) -> Option<Vec<Item>>[src]

Return the entries contained in this ItemValue, if this value is a CompositeList or a CompositeDict.

pub fn get_bytes(&self) -> Option<Vec<u8>>[src]

Get the bytes conatined in this ItemValue, if this value is a Bytes.

pub fn get_utf8(&self) -> Option<String>[src]

Get the UTF-8 string contained in this ItemValue, if this value is a UTF8.

pub fn get_bool(&self) -> Option<bool>[src]

Get the boolean contained in this ItemValue, if this value is a Boolean.

pub fn get_i64(&self) -> Option<i64>[src]

Get the i64 contained in this ItemValue, if this value is a Int64, a SVarInt, or a Stamp64.

pub fn get_u64(&self) -> Option<u64>[src]

Get the u64 contained in this ItemValue, if this value is a UVarInt.

pub fn get_f64(&self) -> Option<f64>[src]

Get the f64 contained in this ItemValue, if this value is a Float64.

Trait Implementations

impl Clone for ItemValue[src]

impl Debug for ItemValue[src]

impl PartialEq<ItemValue> for ItemValue[src]

impl StructuralPartialEq for ItemValue[src]

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