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 fn as_str() -> &'static str {15 from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")16 }1718 19 fn is_dynamic() -> bool;2021 22 fn size() -> usize;23}242526pub trait AbiRead {27 28 fn abi_read(reader: &mut AbiReader) -> Result<Self>29 where30 Self: Sized;31}32333435pub trait AbiWrite {36 37 fn abi_write(&self, writer: &mut AbiWriter);38 39 40 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {41 let mut writer = AbiWriter::new();42 self.abi_write(&mut writer);43 Ok(writer.into())44 }45}