pub struct StructBuf<T> where
T: for<'a> Struct<'a>, { /* 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.
use flatdata::StructBuf;
define_struct!(
A,
RefA,
RefMutA,
"no_schema",
4,
(x, set_x, u32, 0, 16),
(y, set_y, u32, 16, 16)
);
let mut a = StructBuf::<A>::new();
a.get_mut().set_x(1);
a.get_mut().set_y(2);
assert_eq!(a.get().x(), 1);
assert_eq!(a.get().y(), 2);
Creates an empty struct buffer.
All fields are set to 0.
Get the mutable version of the stored object
Returns a raw bytes representation of the buffer.
Returns the "default value" for a type. Read more
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static