fixed-map 0.9.6

A fixed map where storage layout is calculated by a procedural macro.
Documentation
//! Raw access to underlying storage.
//!
//! This can be useful to implement more efficient serialization, since it might
//! provide access to smaller primitive values.

/// Trait implemented for storage which can be easily converted to and from a
/// raw value.
///
/// This is implemented for [`SetStorage`] when the `#[key(bitset)]` attribute
/// is present.
///
/// [`SetStorage`]: crate::set::SetStorage
pub trait RawStorage: Sized {
    /// The backing raw value.
    type Value;

    /// Get the raw value of the storage.
    fn as_raw(&self) -> Self::Value;

    /// Build storage from raw storage.
    fn from_raw(raw: Self::Value) -> Self;
}

/// Raw storage which is laid out exactly like its [`RawStorage::Value`].
///
/// This is implemented for [`SetStorage`] when the `#[key(bitset)]` attribute
/// is present, and lets [`Set`] implement layout-dependent traits like
/// `ZeroCopy` from `musli-zerocopy`.
///
/// # Safety
///
/// The implementor must be `#[repr(transparent)]` over a single field of type
/// [`RawStorage::Value`], every bit pattern of that value must be a valid
/// instance of the storage, and [`RawStorage::as_raw`] and
/// [`RawStorage::from_raw`] must copy that field unchanged.
///
/// [`SetStorage`]: crate::set::SetStorage
/// [`Set`]: crate::Set
pub unsafe trait TransparentRawStorage: RawStorage {}