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 mod sealed {27 28 pub trait CanBePlacedInVec {}29}303132pub trait AbiRead {33 34 fn abi_read(reader: &mut AbiReader) -> Result<Self>35 where36 Self: Sized;37}38394041pub trait AbiWrite {42 43 fn abi_write(&self, writer: &mut AbiWriter);44 45 46 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {47 let mut writer = AbiWriter::new();48 self.abi_write(&mut writer);49 Ok(writer.into())50 }51}