1#![doc(html_favicon_url = "https://dev.namada.net/master/favicon.png")]
4#![doc(html_logo_url = "https://dev.namada.net/master/rustdoc-logo.png")]
5#![deny(rustdoc::broken_intra_doc_links)]
6#![deny(rustdoc::private_intra_doc_links)]
7#![warn(
8 missing_docs,
9 rust_2018_idioms,
10 clippy::cast_sign_loss,
11 clippy::cast_possible_truncation,
12 clippy::cast_possible_wrap,
13 clippy::cast_lossless,
14 clippy::arithmetic_side_effects,
15 clippy::dbg_macro,
16 clippy::print_stdout,
17 clippy::print_stderr
18)]
19#![cfg_attr(feature = "arbitrary", allow(clippy::disallowed_methods))]
20
21pub mod arith;
22pub mod borsh;
23pub mod bytes;
24#[cfg(any(test, feature = "control_flow"))]
25pub mod control_flow;
26pub mod hints;
27
28pub use masp_primitives;
29pub mod tendermint {
31 pub mod abci {
33 pub use tendermint::abci::response::ApplySnapshotChunkResult;
34 pub use tendermint::abci::{
35 Code, Event, EventAttribute, MethodKind, types,
36 };
37 pub use tendermint::v0_37::abci::*;
38 }
39 pub use tendermint::*;
40}
41pub mod tendermint_proto {
43 pub use tendermint_proto::google; pub use tendermint_proto::v0_37::*;
45}
46
47#[allow(missing_docs)]
48pub mod collections {
49 pub mod hash_map {
52 pub use indexmap::map::{IndexMap as HashMap, *};
53 }
54
55 pub mod hash_set {
56 pub use indexmap::set::{IndexSet as HashSet, *};
57 }
58
59 pub use hash_map::HashMap;
60 pub use hash_set::HashSet;
61}
62
63pub mod address;
64pub mod booleans;
65pub mod chain;
66pub mod dec;
67pub mod eth_abi;
68pub mod eth_bridge_pool;
69pub mod ethereum_events;
70pub mod ethereum_structs;
71pub mod hash;
72pub mod ibc;
73pub mod internal;
74pub mod keccak;
75pub mod key;
76pub mod masp;
77pub mod parameters;
78pub mod storage;
79pub mod string_encoding;
80#[cfg(any(test, feature = "task_env"))]
81pub mod task_env;
82pub mod time;
83pub mod token;
84pub mod uint;
85pub mod validity_predicate;
86pub mod voting_power;
87
88use thiserror::Error;
89
90use crate::borsh::{BorshDeserialize, BorshSerialize, BorshSerializeExt};
91
92include!(concat!(env!("OUT_DIR"), "/consensus_version.rs"));
94
95#[allow(missing_docs)]
96#[derive(Error, Debug)]
97pub enum DecodeError {
98 #[error("Deserialization error: {0}")]
99 DeserializationError(std::io::Error),
100}
101
102pub fn encode<T>(value: &T) -> Vec<u8>
104where
105 T: BorshSerialize,
106{
107 value.serialize_to_vec()
108}
109
110pub fn decode<T>(bytes: impl AsRef<[u8]>) -> Result<T, DecodeError>
112where
113 T: BorshDeserialize,
114{
115 T::try_from_slice(bytes.as_ref()).map_err(DecodeError::DeserializationError)
116}