Struct flatdata::StructBuf[][src]

pub struct StructBuf<T: Struct> { /* fields omitted */ }

A container holding a single flatdata struct in memory, and providing read and write access to it.

Used in combination with ArchiveBuilder to serialize single struct resources, cf. coappearances example.

A struct buffer derefs (const and mut) to a reference of the underlying struct, therefore, struct getters and setters can be used directly on buffer.

Examples

use flatdata::StructBuf;

define_struct!(A, AMut, "no_schema", 4,
    (x, set_x, u32, 0, 16),
    (y, set_y, u32, 16, 16)
);

let mut a = StructBuf::<A>::new();
a.set_x(1);
a.set_y(2);
assert_eq!(a.x(), 1);
assert_eq!(a.y(), 2);

Methods

impl<T: Struct> StructBuf<T>
[src]

Creates an empty struct buffer.

All fields are set to 0.

Returns a raw bytes representation of the buffer.

Trait Implementations

impl<T: Struct> Debug for StructBuf<T>
[src]

Formats the value using the given formatter. Read more

impl<T: Struct> Default for StructBuf<T>
[src]

Returns the "default value" for a type. Read more

impl<T: Struct> Deref for StructBuf<T>
[src]

The resulting type after dereferencing.

Dereferences the value.

impl<T: Struct> DerefMut for StructBuf<T>
[src]

Mutably dereferences the value.

impl<T: Struct> AsRef<[u8]> for StructBuf<T>
[src]

Performs the conversion.

Auto Trait Implementations

impl<T> Send for StructBuf<T> where
    <T as Struct>::Mut: Send

impl<T> Sync for StructBuf<T> where
    <T as Struct>::Mut: Sync