owasm_abi/eth/
mod.rs

1//! Legacy Ethereum-like ABI generator
2
3#![warn(missing_docs)]
4
5mod util;
6mod log;
7mod stream;
8mod sink;
9mod common;
10#[cfg(test)]
11mod tests;
12
13pub use self::stream::Stream;
14pub use self::sink::Sink;
15
16/// Error for decoding rust types from stream
17#[derive(Debug, PartialEq, Eq)]
18pub enum Error {
19	/// Invalid bool for provided input
20	InvalidBool,
21	/// Invalid u32 for provided input
22	InvalidU32,
23	/// Invalid u64 for provided input
24	InvalidU64,
25	/// Unexpected end of the stream
26	UnexpectedEof,
27	/// Invalid padding for fixed type
28	InvalidPadding,
29	/// Other error
30	Other,
31}
32
33/// Abi type trait
34pub trait AbiType : Sized {
35	/// Insantiate type from data stream
36	/// Should never be called manually! Use stream.pop()
37	fn decode(stream: &mut Stream) -> Result<Self, Error>;
38
39	/// Push type to data sink
40	/// Should never be called manually! Use sink.push(val)
41	fn encode(self, sink: &mut Sink);
42
43	/// Whether type has fixed length or not
44	const IS_FIXED: bool;
45}
46
47/// Endpoint interface for contracts
48pub trait EndpointInterface {
49	/// Dispatch payload for regular method
50	fn dispatch(&mut self, payload: &[u8]) -> Vec<u8>;
51
52	/// Dispatch constructor payload
53	fn dispatch_ctor(&mut self, payload: &[u8]);
54}