-
-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathmod.rs
62 lines (51 loc) · 1.93 KB
/
mod.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
//! The provided transports.
//!
//! This module exposes all transports that are compiled into the sentry
//! library. The `reqwest`, `curl` and `surf` features turn on these transports.
use crate::{ClientOptions, Transport, TransportFactory};
use std::sync::Arc;
#[cfg(any(feature = "reqwest", feature = "curl", feature = "surf"))]
mod ratelimit;
#[cfg(any(feature = "reqwest", feature = "curl", feature = "surf"))]
mod thread;
#[cfg(feature = "reqwest")]
mod reqwest;
#[cfg(feature = "reqwest")]
pub use reqwest::ReqwestHttpTransport;
#[cfg(feature = "curl")]
mod curl;
#[cfg(feature = "curl")]
pub use curl::CurlHttpTransport;
#[cfg(feature = "surf")]
mod surf;
#[cfg(feature = "surf")]
pub use surf::SurfHttpTransport;
#[cfg(feature = "reqwest")]
type DefaultTransport = ReqwestHttpTransport;
#[cfg(all(feature = "curl", not(feature = "reqwest"), not(feature = "surf")))]
type DefaultTransport = CurlHttpTransport;
#[cfg(all(feature = "surf", not(feature = "reqwest"), not(feature = "curl")))]
type DefaultTransport = SurfHttpTransport;
/// The default http transport.
#[cfg(any(feature = "reqwest", feature = "curl", feature = "surf"))]
pub type HttpTransport = DefaultTransport;
/// Creates the default HTTP transport.
///
/// This is the default value for `transport` on the client options. It
/// creates a `HttpTransport`. If no http transport was compiled into the
/// library it will panic on transport creation.
#[derive(Clone)]
pub struct DefaultTransportFactory;
impl TransportFactory for DefaultTransportFactory {
fn create_transport(&self, options: &ClientOptions) -> Arc<dyn Transport> {
#[cfg(any(feature = "reqwest", feature = "curl", feature = "surf"))]
{
Arc::new(HttpTransport::new(options))
}
#[cfg(not(any(feature = "reqwest", feature = "curl", feature = "surf")))]
{
let _ = options;
panic!("sentry crate was compiled without transport")
}
}
}