pub trait FixedStorage { }Expand description
Marker trait asserting that a type owns no heap allocation.
Required by Fixed::new. See the
module documentation for the contract, for what is already implemented,
and for why this is an assertion rather than an enforcement.
No methods — its only purpose is to gate construction of a
Fixed<T>.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
impl FixedStorage for ()
impl FixedStorage for NonZeroI8
impl FixedStorage for NonZeroI16
impl FixedStorage for NonZeroI32
impl FixedStorage for NonZeroI64
impl FixedStorage for NonZeroI128
impl FixedStorage for NonZeroIsize
impl FixedStorage for NonZeroU8
impl FixedStorage for NonZeroU16
impl FixedStorage for NonZeroU32
impl FixedStorage for NonZeroU64
impl FixedStorage for NonZeroU128
impl FixedStorage for NonZeroUsize
impl FixedStorage for bool
impl FixedStorage for char
impl FixedStorage for f32
impl FixedStorage for f64
impl FixedStorage for i8
impl FixedStorage for i16
impl FixedStorage for i32
impl FixedStorage for i64
impl FixedStorage for i128
impl FixedStorage for isize
impl FixedStorage for u8
impl FixedStorage for u16
impl FixedStorage for u32
impl FixedStorage for u64
impl FixedStorage for u128
impl FixedStorage for usize
impl<A: FixedStorage, B: FixedStorage, C: FixedStorage, D: FixedStorage, E: FixedStorage, F: FixedStorage, G: FixedStorage, H: FixedStorage, I: FixedStorage, J: FixedStorage> FixedStorage for (A, B, C, D, E, F, G, H, I, J)
impl<A: FixedStorage, B: FixedStorage, C: FixedStorage, D: FixedStorage, E: FixedStorage, F: FixedStorage, G: FixedStorage, H: FixedStorage, I: FixedStorage> FixedStorage for (A, B, C, D, E, F, G, H, I)
impl<A: FixedStorage, B: FixedStorage, C: FixedStorage, D: FixedStorage, E: FixedStorage, F: FixedStorage, G: FixedStorage, H: FixedStorage> FixedStorage for (A, B, C, D, E, F, G, H)
impl<A: FixedStorage, B: FixedStorage, C: FixedStorage, D: FixedStorage, E: FixedStorage, F: FixedStorage, G: FixedStorage> FixedStorage for (A, B, C, D, E, F, G)
impl<A: FixedStorage, B: FixedStorage, C: FixedStorage, D: FixedStorage, E: FixedStorage, F: FixedStorage> FixedStorage for (A, B, C, D, E, F)
impl<A: FixedStorage, B: FixedStorage, C: FixedStorage, D: FixedStorage, E: FixedStorage> FixedStorage for (A, B, C, D, E)
impl<A: FixedStorage, B: FixedStorage, C: FixedStorage, D: FixedStorage> FixedStorage for (A, B, C, D)
impl<A: FixedStorage, B: FixedStorage, C: FixedStorage> FixedStorage for (A, B, C)
impl<A: FixedStorage, B: FixedStorage> FixedStorage for (A, B)
impl<A: FixedStorage> FixedStorage for (A,)
impl<T: FixedStorage + Zeroize> FixedStorage for Zeroizing<T>
zeroize::Zeroizing<T> holds T inline and wipes it on drop, so it qualifies exactly
when T does.
This one matters out of proportion to its size. Zeroizing is the idiomatic “wipe this
on drop” wrapper from this crate’s only non-optional dependency, so
Fixed<Zeroizing<[u8; 32]>> is a shape people reach for — and because both the trait and
the type are foreign to the caller, the orphan rule leaves them no way to assert it. It
has to be here or it is unavailable.
impl<T: FixedStorage, const N: usize> FixedStorage for [T; N]
An array never reallocates, whatever its length, so it is FixedStorage exactly when
its element type is. This is the impl that covers [u8; N] and the non-byte arrays the
generic arm of fixed_newtype! exists for.
impl<T: FixedStorage> FixedStorage for MaybeUninit<T>
MaybeUninit<T> is T’s storage, initialised or not. No allocation either way.
impl<T: FixedStorage> FixedStorage for Option<T>
An Option adds a discriminant and no heap storage, so it qualifies exactly when its
payload does. Option<[u8; 32]> is a legitimate fixed-size secret; Option<Vec<u8>>
and Option<Box<[u8]>> are both rejected, which is the point.
impl<T: FixedStorage> FixedStorage for Wrapping<T>
Wrapping is a transparent arithmetic wrapper: same storage as its payload.
Implementors§
impl<T: Zeroize + FixedStorage> FixedStorage for Fixed<T>
A Fixed<T> holds T inline, so the wrapper nests: Fixed<Fixed<[u8; 32]>> is legal
exactly when the payload qualifies. Without this impl the crate’s own wrapper could not
be used as its own inner type.