git.delta.rocks / unique-network / refs/commits / 220a98938240

difftreelog

source

crates/evm-coder/src/solidity/traits.rs1.4 KiBsourcehistory
1use super::TypeCollector;2use core::fmt;34pub mod sealed {5	/// Not every type should be directly placed in vec.6	/// Vec encoding is not memory efficient, as every item will be padded7	/// to 32 bytes.8	/// Instead you should use specialized types (`bytes` in case of `Vec<u8>`)9	pub trait CanBePlacedInVec {}10}1112pub trait StructCollect: 'static {13	/// Structure name.14	fn name() -> String;15	/// Structure declaration.16	fn declaration() -> String;17}1819pub trait SolidityTypeName: 'static {20	fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;21	/// "simple" types are stored inline, no `memory` modifier should be used in solidity22	fn is_simple() -> bool;23	fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;24	/// Specialization25	fn is_void() -> bool {26		false27	}28}2930pub trait SolidityTupleType {31	fn names(tc: &TypeCollector) -> Vec<String>;32	fn len() -> usize;33}3435pub trait SolidityArguments {36	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;37	fn solidity_get(&self, prefix: &str, writer: &mut impl fmt::Write) -> fmt::Result;38	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;39	fn is_empty(&self) -> bool {40		self.len() == 041	}42	fn len(&self) -> usize;43}4445pub trait SolidityFunctions {46	fn solidity_name(47		&self,48		is_impl: bool,49		writer: &mut impl fmt::Write,50		tc: &TypeCollector,51	) -> fmt::Result;52}