zink/primitives/
address.rsuse crate::{ffi, storage::StorageValue, Asm};
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Address(
#[cfg(target_family = "wasm")] i32,
#[cfg(not(target_family = "wasm"))] [u8; 20],
);
impl Address {
#[allow(clippy::should_implement_trait)]
pub fn eq(self, other: Self) -> bool {
unsafe { ffi::address_eq(self, other) }
}
}
impl Asm for Address {
fn push(self) {
unsafe { ffi::asm::push_address(self) }
}
#[cfg(not(target_family = "wasm"))]
fn bytes32(&self) -> [u8; 32] {
let mut output = [0; 32];
output[12..].copy_from_slice(&self.0);
output
}
}
impl StorageValue for Address {
fn sload() -> Self {
unsafe { ffi::asm::sload_address() }
}
}