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
use s2n_quic_core::{endpoint::Endpoint, inet::SocketAddress, path::Handle as PathHandle};
use std::io;
pub trait Provider: 'static {
type PathHandle: PathHandle;
type Error: 'static + core::fmt::Display;
fn start<E: Endpoint<PathHandle = Self::PathHandle>>(
self,
endpoint: E,
) -> Result<SocketAddress, Self::Error>;
}
#[cfg(any(test, all(not(docdiff), feature = "unstable-provider-io-testing")))]
pub mod testing;
pub mod tokio;
pub use self::tokio as default;
pub use default::Provider as Default;
impl TryInto for u16 {
type Error = io::Error;
type Provider = Default;
fn try_into(self) -> io::Result<Self::Provider> {
Default::new(("::", self))
}
}
macro_rules! impl_socket_addrs {
($ty:ty) => {
impl TryInto for $ty {
type Error = io::Error;
type Provider = Default;
fn try_into(self) -> io::Result<Self::Provider> {
Default::new(self)
}
}
};
}
impl_socket_addrs!((&str, u16));
impl_socket_addrs!((std::net::IpAddr, u16));
impl_socket_addrs!((std::net::Ipv4Addr, u16));
impl_socket_addrs!((std::net::Ipv6Addr, u16));
impl_socket_addrs!(&str);
impl_socket_addrs!(std::net::SocketAddr);
impl_socket_addrs!(std::net::SocketAddrV4);
impl_socket_addrs!(std::net::SocketAddrV6);
impl_provider_utils!();