1use super::{AbiReader, AbiWriter};2use crate::{3 custom_signature::*,4 execution::{Result, ResultWithPostInfo},5};6use core::str::from_utf8;789pub trait AbiType {10 11 const SIGNATURE: SignatureUnit;1213 14 const FIELDS_COUNT: usize;1516 17 fn as_str() -> &'static str {18 from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")19 }2021 22 fn is_dynamic() -> bool;2324 25 fn size() -> usize;26}272829pub trait AbiRead {30 31 fn abi_read(reader: &mut AbiReader) -> Result<Self>32 where33 Self: Sized;34}35363738pub trait AbiWrite {39 40 fn abi_write(&self, writer: &mut AbiWriter);41 42 43 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {44 let mut writer = AbiWriter::new();45 self.abi_write(&mut writer);46 Ok(writer.into())47 }48}