Struct savefile::Field

source ·
pub struct Field {
    pub name: String,
    pub value: Box<Schema>,
    /* private fields */
}
Expand description

A field is serialized according to its value. The name is just for diagnostics.

Fields§

§name: String

Field name

§value: Box<Schema>

Field type

Implementations§

source§

impl Field

source

pub fn new(name: String, value: Box<Schema>) -> Field

Create a new instance of field, with the given name and type

source

pub unsafe fn unsafe_new( name: String, value: Box<Schema>, offset: Option<usize> ) -> Field

Create a new instance of field, with the given name and type. The offset is the offset of the field within its struct.

§Safety

The offset must be the correct offset of the field within its struct.

source

pub fn layout_compatible(&self, other: &Field) -> bool

Determine if the two fields are laid out identically in memory, in their parent objects.

Trait Implementations§

source§

impl Clone for Field

source§

fn clone(&self) -> Field

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Field

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deserialize for Field

source§

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 Field

source§

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 Field

source§

fn eq(&self, other: &Field) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Field

source§

fn serialize( &self, serializer: &mut Serializer<'_, impl Write> ) -> Result<(), SavefileError>

Serialize self into the given serializer. In versions prior to 0.15, ‘Serializer’ did not accept a type parameter. It now requires a type parameter with the type of writer expected.
source§

impl WithSchema for Field

source§

fn schema(_version: u32, _context: &mut WithSchemaContext) -> Schema

Returns a representation of the schema used by this Serialize implementation for the given version. The WithSchemaContext can be used to guard against recursive data structures. See documentation of WithSchemaContext.
source§

impl StructuralPartialEq for Field

Auto Trait Implementations§

§

impl Freeze for Field

§

impl RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnwindSafe for Field

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.