mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-19 07:26:47 +00:00
from bytes macro
This commit is contained in:
@@ -9,6 +9,17 @@ macro_rules! impl_to_bytes {
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! impl_from_bytes {
|
||||
($struct_name:ident) => {
|
||||
impl $struct_name {
|
||||
pub fn from_bytes(data: &[u8]) -> &Self {
|
||||
bytemuck::from_bytes::<Self>(data)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! impl_account_from_bytes {
|
||||
($struct_name:ident) => {
|
||||
@@ -73,3 +84,11 @@ macro_rules! instruction {
|
||||
$crate::impl_instruction_from_bytes!($struct_name);
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! event {
|
||||
($struct_name:ident) => {
|
||||
$crate::impl_to_bytes!($struct_name);
|
||||
$crate::impl_from_bytes!($struct_name);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user