[][src]Struct packs::structure::generic_struct::GenericStruct

pub struct GenericStruct {
    pub tag_byte: u8,
    pub fields: Vec<Value<()>>,
}

An anonymous, generic variant for structure values. It does denote different structures by a tag_byte field; all fields are written and read as Value in the order in which they were given. This allows for parsing of any structure which is validly encoded, valid in the PackStream specification sense, i.e. the struct marker and the field size, a tag byte denoting the struct type and then a list of the fields.

It does not allow for recursive patterns; in a struct there is no other structure allowed.

Encode and Decode

Encoding and Decoding is given by the generic Pack and Unpack implementation for Value<S> where S: PackableStructSum:

let s = GenericStruct {
        tag_byte: 0x01,
        fields: vec!(Value::Float(42.0), Value::String(String::from("hello world"))),
};

let value = Value::Structure(s);

let mut buffer = Vec::new();
value.encode(&mut buffer).unwrap();

let res = <Value<GenericStruct>>::decode(&mut buffer.as_slice()).unwrap();

assert_eq!(res, value);

Fields

tag_byte: u8fields: Vec<Value<()>>

Trait Implementations

impl Clone for GenericStruct[src]

impl Debug for GenericStruct[src]

impl PackableStructSum for GenericStruct[src]

impl PartialEq<GenericStruct> for GenericStruct[src]

impl StructuralPartialEq for GenericStruct[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<S, T> Pack<T> for S where
    S: PackableStructSum,
    T: Write
[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.

impl<S, T> Unpack<T> for S where
    S: PackableStructSum,
    T: Read
[src]