pub struct SchemaStruct {
pub dbg_name: String,
pub fields: Vec<Field>,
/* private fields */
}Expand description
Schema for a struct.
A struct is serialized by serializing its fields one by one, without any padding. The dbg_name is just for diagnostics. The memory format is given by size, alignment, and the various field offsets. If any field lacks an offset, the memory format is unspecified.
Fields§
§dbg_name: StringDiagnostic value
fields: Vec<Field>Fields of struct
Implementations§
Source§impl SchemaStruct
impl SchemaStruct
Sourcepub fn new(dbg_name: String, fields: Vec<Field>) -> SchemaStruct
pub fn new(dbg_name: String, fields: Vec<Field>) -> SchemaStruct
- dbg_name: The name of the struct
- fields: The fields of the struct
Sourcepub fn new_unsafe(
dbg_name: String,
fields: Vec<Field>,
size: Option<usize>,
alignment: Option<usize>,
) -> SchemaStruct
pub fn new_unsafe( dbg_name: String, fields: Vec<Field>, size: Option<usize>, alignment: Option<usize>, ) -> SchemaStruct
- dbg_name: The name of the struct
- fields: The fields of the struct
- size: If None, the memory layout of the struct is unspecified.
Otherwise, the size of the struct in memory (
std::mem::size_of::<TheStruct>()). - alignment: If None, the memory layout of the struct is unspecified.
Otherwise, the alignment of the struct (
std::mem::align_of::<TheStruct>()).
Trait Implementations§
Source§impl Clone for SchemaStruct
impl Clone for SchemaStruct
Source§fn clone(&self) -> SchemaStruct
fn clone(&self) -> SchemaStruct
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SchemaStruct
impl Debug for SchemaStruct
Source§impl Deserialize for SchemaStruct
impl Deserialize for SchemaStruct
Source§fn deserialize(
deserializer: &mut Deserializer<'_, impl Read>,
) -> Result<Self, SavefileError>
fn deserialize( deserializer: &mut Deserializer<'_, impl Read>, ) -> Result<Self, SavefileError>
Deserialize and return an instance of Self from the given deserializer.
Source§impl Packed for SchemaStruct
impl Packed for SchemaStruct
Source§unsafe fn repr_c_optimization_safe(_version: u32) -> IsPacked
unsafe fn repr_c_optimization_safe(_version: u32) -> IsPacked
This method returns true if the optimization is allowed
for the protocol version given as an argument.
This may return true if and only if the given protocol version
has a serialized format identical to the memory layout of the given protocol version.
Note, the only memory layout existing is that of the most recent version, so
Packed-optimization only works when disk-format is identical to memory version. Read more
Source§impl PartialEq for SchemaStruct
impl PartialEq for SchemaStruct
Source§impl Serialize for SchemaStruct
impl Serialize for SchemaStruct
Source§fn serialize(
&self,
serializer: &mut Serializer<'_, impl Write>,
) -> Result<(), SavefileError>
fn serialize( &self, serializer: &mut Serializer<'_, impl Write>, ) -> Result<(), SavefileError>
Serialize self into the given serializer. Read more
Source§impl WithSchema for SchemaStruct
impl WithSchema for SchemaStruct
impl StructuralPartialEq for SchemaStruct
Auto Trait Implementations§
impl Freeze for SchemaStruct
impl RefUnwindSafe for SchemaStruct
impl Send for SchemaStruct
impl Sync for SchemaStruct
impl Unpin for SchemaStruct
impl UnwindSafe for SchemaStruct
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more