pub use solana_zero_copy::unaligned::{Bool, U16, U32, U64, I16, I64};
#[cfg(not(target_arch = "bpf"))]
pub use solana_zero_copy::unaligned::U128;
use crate::account::{Pod, FixedLayout};
unsafe impl Pod for U16 {}
unsafe impl Pod for U32 {}
unsafe impl Pod for U64 {}
unsafe impl Pod for I16 {}
unsafe impl Pod for I64 {}
unsafe impl Pod for Bool {}
#[cfg(not(target_arch = "bpf"))]
unsafe impl Pod for U128 {}
impl FixedLayout for U16 { const SIZE: usize = 2; }
impl FixedLayout for U32 { const SIZE: usize = 4; }
impl FixedLayout for U64 { const SIZE: usize = 8; }
impl FixedLayout for I16 { const SIZE: usize = 2; }
impl FixedLayout for I64 { const SIZE: usize = 8; }
impl FixedLayout for Bool { const SIZE: usize = 1; }
#[cfg(not(target_arch = "bpf"))]
impl FixedLayout for U128 { const SIZE: usize = 16; }
use crate::abi::{LeBool, LeI16, LeU128, LeU16, LeU32, LeU64};
macro_rules! impl_le_szc_bridge {
($le:ty, $szc:ty) => {
impl From<$le> for $szc {
#[inline(always)]
fn from(v: $le) -> Self {
Self(v.0)
}
}
impl From<$szc> for $le {
#[inline(always)]
fn from(v: $szc) -> Self {
Self(v.0)
}
}
};
}
impl_le_szc_bridge!(LeU16, U16);
impl_le_szc_bridge!(LeU32, U32);
impl_le_szc_bridge!(LeU64, U64);
impl_le_szc_bridge!(LeI16, I16);
impl From<crate::abi::LeI64> for I64 {
#[inline(always)]
fn from(v: crate::abi::LeI64) -> Self {
Self::from_primitive(v.get())
}
}
impl From<I64> for crate::abi::LeI64 {
#[inline(always)]
fn from(v: I64) -> Self {
Self::new(i64::from(v))
}
}
impl From<LeBool> for Bool {
#[inline(always)]
fn from(v: LeBool) -> Self {
Self(v.0[0])
}
}
impl From<Bool> for LeBool {
#[inline(always)]
fn from(v: Bool) -> Self {
Self([v.0])
}
}
#[cfg(not(target_arch = "bpf"))]
impl From<LeU128> for U128 {
#[inline(always)]
fn from(v: LeU128) -> Self {
Self(v.0)
}
}
#[cfg(not(target_arch = "bpf"))]
impl From<U128> for LeU128 {
#[inline(always)]
fn from(v: U128) -> Self {
Self(v.0)
}
}