Trait savefile::ReprC

source ·
pub trait ReprC {
    // Provided method
    unsafe fn repr_c_optimization_safe(_version: u32) -> IsReprC { ... }
}
Expand description

This trait describes whether a type is such that it can just be blitted. See method repr_c_optimization_safe.

Provided Methods§

source

unsafe fn repr_c_optimization_safe(_version: u32) -> IsReprC

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 given protocol version.

This can return true for types which have an in-memory layout that is packed and therefore identical to the layout that savefile will use on disk. This means that types for which this trait is implemented can be serialized very quickly by just writing their raw bits to disc.

Rules to allow returning true:

  • The type must be copy
  • The type must not contain any padding (if there is padding, backward compatibility will fail, since in fallback mode regular savefile-deserialize will be used, and it will not use padding)
  • The type must have a strictly deterministic memory layout (no field order randomization). This typically means repr(C)
  • All the constituent types of the type must also implement ReprC (correctly).

Constructing an instance of ‘IsReprC’ with value ‘true’ is not safe. See documentation of ‘IsReprC’. The idea is that the ReprC-trait itself can still be safe to implement, it just won’t be possible to get hold of an instance of IsReprC(true). To make it impossible to just ‘steal’ such a value from some other thing implementign ‘ReprC’, this method is marked unsafe.

§SAFETY

The returned value must not be used, except by the Savefile-framework. It must not be be forwarded anywhere else.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ReprC for bool

source§

impl ReprC for char

source§

impl ReprC for f32

source§

impl ReprC for f64

source§

impl ReprC for i8

source§

impl ReprC for i16

source§

impl ReprC for i32

source§

impl ReprC for i64

source§

impl ReprC for i128

source§

impl ReprC for isize

source§

impl ReprC for u8

source§

impl ReprC for u16

source§

impl ReprC for u32

source§

impl ReprC for u64

source§

impl ReprC for u128

source§

impl ReprC for ()

source§

impl ReprC for usize

source§

impl ReprC for BitSet<u32>

source§

impl ReprC for BitVec<u32>

source§

impl ReprC for String

source§

impl ReprC for Arc<str>

source§

impl ReprC for AtomicBool

source§

impl ReprC for AtomicI8

source§

impl ReprC for AtomicI16

source§

impl ReprC for AtomicI32

source§

impl ReprC for AtomicI64

source§

impl ReprC for AtomicIsize

source§

impl ReprC for AtomicU8

source§

impl ReprC for AtomicU16

source§

impl ReprC for AtomicU32

source§

impl ReprC for AtomicU64

source§

impl ReprC for AtomicUsize

source§

impl ReprC for PathBuf

source§

impl<'a, T: 'a + ToOwned + ?Sized> ReprC for Cow<'a, T>

source§

impl<K, S: BuildHasher> ReprC for HashSet<K, S>

source§

impl<K, V> ReprC for BTreeMap<K, V>

source§

impl<K: Eq + Hash, S: BuildHasher> ReprC for IndexSet<K, S>

source§

impl<K: Eq + Hash, V, S: BuildHasher> ReprC for IndexMap<K, V, S>

source§

impl<K: Eq + Hash, V, S: BuildHasher> ReprC for HashMap<K, V, S>

source§

impl<T1> ReprC for Range<T1>

source§

impl<T1: ReprC> ReprC for (T1,)

source§

impl<T1: ReprC, T2: ReprC> ReprC for (T1, T2)

source§

impl<T1: ReprC, T2: ReprC, T3: ReprC> ReprC for (T1, T2, T3)

source§

impl<T1: ReprC, T2: ReprC, T3: ReprC, T4: ReprC> ReprC for (T1, T2, T3, T4)

source§

impl<T> ReprC for Option<T>

source§

impl<T> ReprC for Box<T>

source§

impl<T> ReprC for BinaryHeap<T>

source§

impl<T> ReprC for VecDeque<T>

source§

impl<T> ReprC for Rc<T>

source§

impl<T> ReprC for Arc<T>

source§

impl<T> ReprC for Vec<T>

source§

impl<T> ReprC for RefCell<T>

source§

impl<T> ReprC for PhantomData<T>

source§

impl<T> ReprC for Mutex<T>

source§

impl<T> ReprC for Mutex<T>

source§

impl<T> ReprC for RwLock<T>

source§

impl<T: Array> ReprC for SmallVec<T>

source§

impl<T: ReprC> ReprC for Box<[T]>

source§

impl<T: ReprC> ReprC for Arc<[T]>

source§

impl<T: ReprC> ReprC for Cell<T>

source§

impl<T: ReprC, const N: usize> ReprC for [T; N]

source§

impl<V: ReprC, const C: usize> ReprC for ArrayVec<V, C>

source§

impl<const C: usize> ReprC for ArrayString<C>

Implementors§