[−][src]Struct packs::structure::generic_struct::GenericStruct
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: u8
fields: Vec<Value<()>>
Trait Implementations
impl Clone for GenericStruct
[src]
fn clone(&self) -> GenericStruct
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for GenericStruct
[src]
impl PackableStructSum for GenericStruct
[src]
fn read_struct_body<T: Read>(
size: usize,
tag_byte: u8,
reader: &mut T
) -> Result<Self, DecodeError>
[src]
size: usize,
tag_byte: u8,
reader: &mut T
) -> Result<Self, DecodeError>
fn write_struct_body<T: Write>(
&self,
writer: &mut T
) -> Result<usize, EncodeError>
[src]
&self,
writer: &mut T
) -> Result<usize, EncodeError>
fn fields_len(&self) -> usize
[src]
fn tag_byte(&self) -> u8
[src]
impl PartialEq<GenericStruct> for GenericStruct
[src]
fn eq(&self, other: &GenericStruct) -> bool
[src]
fn ne(&self, other: &GenericStruct) -> bool
[src]
impl StructuralPartialEq for GenericStruct
[src]
Auto Trait Implementations
impl RefUnwindSafe for GenericStruct
impl Send for GenericStruct
impl Sync for GenericStruct
impl Unpin for GenericStruct
impl UnwindSafe for GenericStruct
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,
pub 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<S, T> Pack<T> for S where
S: PackableStructSum,
T: Write,
[src]
S: PackableStructSum,
T: Write,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<S, T> Unpack<T> for S where
S: PackableStructSum,
T: Read,
[src]
S: PackableStructSum,
T: Read,