-
Notifications
You must be signed in to change notification settings - Fork 256
/
Copy pathlib.rs
92 lines (74 loc) · 2.63 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg",
html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico"
)]
#![warn(
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
unreachable_pub,
clippy::missing_const_for_fn,
rustdoc::all
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
mod boxed;
pub use boxed::BoxTransport;
mod connect;
pub use connect::{BoxTransportConnect, TransportConnect};
mod common;
pub use common::Authorization;
mod error;
#[doc(hidden)]
pub use error::TransportErrorKind;
pub use error::{TransportError, TransportResult};
mod r#trait;
pub use r#trait::Transport;
pub use alloy_json_rpc::{RpcError, RpcResult};
/// Misc. utilities for building transports.
pub mod utils;
pub use type_aliases::*;
#[cfg(not(target_arch = "wasm32"))]
mod type_aliases {
use crate::{TransportError, TransportResult};
use alloy_json_rpc::ResponsePacket;
/// Pin-boxed future.
pub type Pbf<'a, T, E> =
std::pin::Pin<Box<dyn std::future::Future<Output = Result<T, E>> + Send + 'a>>;
/// Future for Transport-level requests.
pub type TransportFut<'a, T = ResponsePacket, E = TransportError> =
std::pin::Pin<Box<dyn std::future::Future<Output = Result<T, E>> + Send + 'a>>;
/// Future for RPC-level requests.
pub type RpcFut<'a, T> =
std::pin::Pin<Box<dyn std::future::Future<Output = TransportResult<T>> + Send + 'a>>;
/// `impl Future` with a `Send` bound.
#[macro_export]
macro_rules! impl_future {
(<$($t:tt)+) => {
impl (::core::future::Future<$($t)+) + Send
};
}
}
#[cfg(target_arch = "wasm32")]
mod type_aliases {
use crate::{TransportError, TransportResult};
use alloy_json_rpc::ResponsePacket;
/// Pin-boxed future.
pub type Pbf<'a, T, E> =
std::pin::Pin<Box<dyn std::future::Future<Output = Result<T, E>> + 'a>>;
/// Future for Transport-level requests.
pub type TransportFut<'a, T = ResponsePacket, E = TransportError> =
std::pin::Pin<Box<dyn std::future::Future<Output = Result<T, E>> + 'a>>;
/// Future for RPC-level requests.
pub type RpcFut<'a, T> =
std::pin::Pin<Box<dyn std::future::Future<Output = TransportResult<T>> + 'a>>;
/// `impl Future` without a `Send` bound.
#[macro_export]
macro_rules! impl_future {
(<$($t:tt)+) => {
impl ::core::future::Future<$($t)+
};
}
}