git.delta.rocks / unique-network / refs/commits / 27a93db3a4a4

difftreelog

source

crates/evm-coder/src/solidity/traits.rs1.2 KiBsourcehistory
1use super::TypeCollector;2use core::fmt;34pub trait StructCollect: 'static {5	/// Structure name.6	fn name() -> String;7	/// Structure declaration.8	fn declaration() -> String;9}1011pub trait SolidityEnum: 'static {12	fn solidity_option(&self) -> &str;13}1415pub trait SolidityTypeName: 'static {16	fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;17	/// "simple" types are stored inline, no `memory` modifier should be used in solidity18	fn is_simple() -> bool;19	fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;20	/// Specialization21	fn is_void() -> bool {22		false23	}24}2526pub trait SolidityType {27	fn names(tc: &TypeCollector) -> Vec<String>;28	fn len() -> usize;29}3031pub trait SolidityArguments {32	fn solidity_name(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;33	fn solidity_get(&self, prefix: &str, writer: &mut impl fmt::Write) -> fmt::Result;34	fn solidity_default(&self, writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;35	fn is_empty(&self) -> bool {36		self.len() == 037	}38	fn len(&self) -> usize;39}4041pub trait SolidityFunctions {42	fn solidity_name(43		&self,44		is_impl: bool,45		writer: &mut impl fmt::Write,46		tc: &TypeCollector,47	) -> fmt::Result;48}