pub struct VersionedBytes<'a> {
pub format_identifier: [u8; 24],
pub version: u64,
pub data: &'a [u8],
}Expand description
A set of bytes accompanied by file header information.
Buffers deserialized using rkyv must be aligned to 16-byte boundaries. VersionedBytes is capable of preserving 16-byte memory alignment if the backing byte buffer is correctly aligned.
Fields§
§format_identifier: [u8; 24]The magic bytes at the start of the file indicating the format used.
version: u64The format version stored within the header.
data: &'a [u8]The data following the header.
Implementations§
Source§impl<'a> VersionedBytes<'a>
impl<'a> VersionedBytes<'a>
Sourcepub fn try_from_bytes(
value: &'a [u8],
format_identifier: [u8; 24],
) -> Option<Self>
pub fn try_from_bytes( value: &'a [u8], format_identifier: [u8; 24], ) -> Option<Self>
Tries to deserialize a VersionedBytes struct from a byte array.
This can fail in the following cases:
- The specified
format_identifierdoes not match the first 24 bytes of the byte array - The byte array is less than 32 bytes long
Sourcepub const fn output_length(&self) -> usize
pub const fn output_length(&self) -> usize
The total length in bytes after serialization.
Trait Implementations§
Source§impl<'a> Clone for VersionedBytes<'a>
impl<'a> Clone for VersionedBytes<'a>
Source§fn clone(&self) -> VersionedBytes<'a>
fn clone(&self) -> VersionedBytes<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for VersionedBytes<'a>
Source§impl<'a> Debug for VersionedBytes<'a>
impl<'a> Debug for VersionedBytes<'a>
impl<'a> Eq for VersionedBytes<'a>
Source§impl<'a> Hash for VersionedBytes<'a>
impl<'a> Hash for VersionedBytes<'a>
Source§impl<'a> Ord for VersionedBytes<'a>
impl<'a> Ord for VersionedBytes<'a>
Source§fn cmp(&self, other: &VersionedBytes<'a>) -> Ordering
fn cmp(&self, other: &VersionedBytes<'a>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialEq for VersionedBytes<'a>
impl<'a> PartialEq for VersionedBytes<'a>
Source§impl<'a> PartialOrd for VersionedBytes<'a>
impl<'a> PartialOrd for VersionedBytes<'a>
impl<'a> StructuralPartialEq for VersionedBytes<'a>
Auto Trait Implementations§
impl<'a> Freeze for VersionedBytes<'a>
impl<'a> RefUnwindSafe for VersionedBytes<'a>
impl<'a> Send for VersionedBytes<'a>
impl<'a> Sync for VersionedBytes<'a>
impl<'a> Unpin for VersionedBytes<'a>
impl<'a> UnsafeUnpin for VersionedBytes<'a>
impl<'a> UnwindSafe for VersionedBytes<'a>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.