alloy_primitives/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(
3    html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg",
4    html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico"
5)]
6#![cfg_attr(not(test), warn(unused_crate_dependencies))]
7#![cfg_attr(not(feature = "std"), no_std)]
8#![cfg_attr(feature = "nightly", feature(hasher_prefixfree_extras))]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10
11#[macro_use]
12extern crate alloc;
13
14use paste as _;
15#[cfg(feature = "sha3-keccak")]
16use sha3 as _;
17use tiny_keccak as _;
18
19#[cfg(feature = "postgres")]
20pub mod postgres;
21
22#[cfg(feature = "diesel")]
23pub mod diesel;
24
25#[cfg(feature = "sqlx")]
26pub mod sqlx;
27
28pub mod aliases;
29#[doc(no_inline)]
30pub use aliases::{
31    B64, B128, B256, B512, BlockHash, BlockNumber, BlockTimestamp, ChainId, I8, I16, I32, I64,
32    I128, I160, I256, Selector, StorageKey, StorageValue, TxHash, TxIndex, TxNonce, TxNumber, U8,
33    U16, U32, U64, U128, U160, U256, U512,
34};
35
36#[macro_use]
37mod bits;
38pub use bits::{
39    Address, AddressChecksumBuffer, AddressError, BLOOM_BITS_PER_ITEM, BLOOM_SIZE_BITS,
40    BLOOM_SIZE_BYTES, Bloom, BloomInput, FixedBytes, Function,
41};
42#[cfg(feature = "rkyv")]
43pub use bits::{
44    AddressResolver, ArchivedAddress, ArchivedBloom, ArchivedFixedBytes, BloomResolver,
45    FixedBytesResolver,
46};
47
48#[path = "bytes/mod.rs"]
49mod bytes_;
50pub use self::bytes_::Bytes;
51
52mod common;
53pub use common::TxKind;
54
55mod log;
56pub use log::{IntoLogData, Log, LogData, logs_bloom};
57
58#[cfg(feature = "map")]
59pub mod map;
60
61mod sealed;
62pub use sealed::{Sealable, Sealed};
63
64mod signed;
65pub use signed::{BigIntConversionError, ParseSignedError, Sign, Signed};
66
67mod signature;
68#[allow(deprecated)]
69pub use signature::PrimitiveSignature;
70pub use signature::{Signature, SignatureError, normalize_v, to_eip155_v};
71
72pub mod utils;
73pub use utils::{KECCAK256_EMPTY, Keccak256, eip191_hash_message, keccak256};
74
75#[doc(hidden)] // Use `hex` directly instead!
76pub mod hex_literal;
77
78#[doc(inline)]
79pub use ruint::uint;
80#[doc(no_inline)]
81pub use {
82    ::bytes,
83    ::hex,
84    ruint::{self, Uint},
85};
86
87#[cfg(feature = "serde")]
88#[doc(no_inline)]
89pub use ::hex::serde as serde_hex;
90
91/// 20-byte [fixed byte-array][FixedBytes] type.
92///
93/// You'll likely want to use [`Address`] instead, as it is a different type
94/// from `FixedBytes<20>`, and implements methods useful for working with
95/// Ethereum addresses.
96///
97/// If you are sure you want to use this type, and you don't want the
98/// deprecation warning, you can use `aliases::B160`.
99#[deprecated(
100    since = "0.3.2",
101    note = "you likely want to use `Address` instead. \
102            `B160` and `Address` are different types, \
103            see this type's documentation for more."
104)]
105pub type B160 = FixedBytes<20>;
106
107// Not public API.
108#[doc(hidden)]
109pub mod private {
110    pub use alloc::vec::Vec;
111    pub use core::{
112        self,
113        borrow::{Borrow, BorrowMut},
114        cmp::Ordering,
115        prelude::rust_2021::*,
116    };
117    pub use derive_more;
118
119    #[cfg(feature = "getrandom")]
120    pub use getrandom;
121
122    #[cfg(feature = "rand")]
123    pub use rand;
124
125    #[cfg(feature = "rlp")]
126    pub use alloy_rlp;
127
128    #[cfg(feature = "allocative")]
129    pub use allocative;
130
131    #[cfg(feature = "serde")]
132    pub use serde;
133
134    #[cfg(feature = "borsh")]
135    pub use borsh;
136
137    #[cfg(feature = "arbitrary")]
138    pub use {arbitrary, proptest, proptest_derive};
139
140    #[cfg(feature = "diesel")]
141    pub use diesel;
142
143    #[cfg(feature = "sqlx")]
144    pub use sqlx_core;
145}