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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use cfg_if::cfg_if;
use core::fmt;

#[macro_use]
mod macros;

pub mod address_token;
pub mod connection_id;
pub mod endpoint_limits;
pub mod event;
pub mod io;
pub mod limits;
pub mod stateless_reset_token;
pub mod tls;

// These providers are not currently exposed to applications
pub(crate) mod connection_close_formatter;
pub(crate) mod path_migration;
pub(crate) mod sync;

cfg_if!(
    if #[cfg(any(test, all(not(docdiff), feature = "unstable-provider-packet-interceptor")))] {
        pub mod packet_interceptor;
    } else {
        pub(crate) mod packet_interceptor;
    }
);

cfg_if!(
    if #[cfg(any(test, all(not(docdiff), feature = "unstable-provider-random")))] {
        pub mod random;
    } else {
        pub(crate) mod random;
    }
);

cfg_if!(
    if #[cfg(any(test, all(not(docdiff), feature = "unstable-provider-datagram")))] {
        pub mod datagram;
    } else {
        pub(crate) mod datagram;
    }
);

cfg_if!(
    if #[cfg(any(test, all(not(docdiff), feature = "unstable-provider-congestion-controller")))] {
        pub mod congestion_controller;
    } else {
        pub(crate) mod congestion_controller;
    }
);

/// An error indicating a failure to start an endpoint
pub struct StartError(Box<dyn 'static + fmt::Display>);

impl std::error::Error for StartError {}

impl StartError {
    pub(crate) fn new<T: 'static + fmt::Display>(error: T) -> Self {
        Self(Box::new(error))
    }
}

impl fmt::Debug for StartError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_tuple("StartError")
            .field(&format_args!("{}", self.0))
            .finish()
    }
}

impl fmt::Display for StartError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        self.0.fmt(f)
    }
}