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]
pub fn new() -> Self
[src]
Creates an empty struct buffer.
All fields are set to 0.
pub fn as_bytes(&self) -> &[u8]
[src]
Returns a raw bytes representation of the buffer.
Trait Implementations
impl<T: Struct> Debug for StructBuf<T>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: Struct> Default for StructBuf<T>
[src]
impl<T: Struct> Deref for StructBuf<T>
[src]
type Target = T::Mut
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
Dereferences the value.