[][src]Trait rkyv::ArchiveSelf

pub unsafe trait ArchiveSelf: Archive<Archived = Self> + Copy { }

A trait that indicates that some Archive type can be copied directly to an archive without additional processing.

You can derive an implementation of ArchiveSelf by adding #[archive(self)] to the struct or enum. Types that implement ArchiveSelf must also implement Copy.

Types that implement ArchiveSelf are not guaranteed to have archive called on them to archive their value. Most or all implementations that leverage ArchiveSelf will require the specialization feature.

ArchiveSelf must be manually implemented even if a type implements Archive and Copy because some types may transform their data when writing to an archive.

Examples

use rkyv::{Aligned, Archive, ArchiveBuffer, archived_value, Write, WriteExt};

#[derive(Archive, Clone, Copy, Debug, PartialEq)]
#[archive(self)]
struct Vector4<T>(T, T, T, T);

let mut writer = ArchiveBuffer::new(Aligned([0u8; 256]));
let value = Vector4(1f32, 2f32, 3f32, 4f32);
let pos = writer.archive(&value)
    .expect("failed to archive Vector4");
let buf = writer.into_inner();
let archived_value = unsafe { archived_value::<Vector4<f32>>(buf.as_ref(), pos) };
assert_eq!(&value, archived_value);

Implementations on Foreign Types

impl ArchiveSelf for RangeFull[src]

impl ArchiveSelf for ()[src]

impl ArchiveSelf for bool[src]

impl ArchiveSelf for i8[src]

impl ArchiveSelf for i16[src]

impl ArchiveSelf for i32[src]

impl ArchiveSelf for i64[src]

impl ArchiveSelf for i128[src]

impl ArchiveSelf for u8[src]

impl ArchiveSelf for u16[src]

impl ArchiveSelf for u32[src]

impl ArchiveSelf for u64[src]

impl ArchiveSelf for u128[src]

impl ArchiveSelf for f32[src]

impl ArchiveSelf for f64[src]

impl ArchiveSelf for char[src]

impl ArchiveSelf for NonZeroI8[src]

impl ArchiveSelf for NonZeroI16[src]

impl ArchiveSelf for NonZeroI32[src]

impl ArchiveSelf for NonZeroI64[src]

impl ArchiveSelf for NonZeroI128[src]

impl ArchiveSelf for NonZeroU8[src]

impl ArchiveSelf for NonZeroU16[src]

impl ArchiveSelf for NonZeroU32[src]

impl ArchiveSelf for NonZeroU64[src]

impl ArchiveSelf for NonZeroU128[src]

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

Loading content...

Implementors

Loading content...