light_zero_copy/
lib.rs

1#![no_std]
2
3pub mod cyclic_vec;
4pub mod errors;
5#[cfg(feature = "std")]
6pub mod num_trait;
7pub mod slice;
8pub mod slice_mut;
9pub mod vec;
10use core::mem::{align_of, size_of};
11#[cfg(feature = "std")]
12pub mod borsh;
13
14use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
15
16#[cfg(feature = "std")]
17extern crate std;
18
19pub fn add_padding<LEN, T>(offset: &mut usize) {
20    let padding = align_of::<T>().saturating_sub(size_of::<LEN>());
21    *offset += padding;
22}
23pub trait ZeroCopyTraits: Copy + KnownLayout + Immutable + FromBytes + IntoBytes {}
24
25impl<T> ZeroCopyTraits for T where T: Copy + KnownLayout + Immutable + FromBytes + IntoBytes {}