Fix compilation with --no-default-features
This commit is contained in:
parent
c1b118f378
commit
ed73ff546f
|
@ -34,6 +34,10 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --all-features
|
args: --all-features
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --no-default-features
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -1,22 +1,12 @@
|
||||||
use std::io;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use tracing::{debug, error};
|
||||||
#[cfg(feature = "tokio-rustls")]
|
|
||||||
use tokio::net::lookup_host;
|
|
||||||
use tokio::net::TcpStream;
|
|
||||||
#[cfg(feature = "tokio-rustls")]
|
|
||||||
use tokio_rustls::client::TlsStream;
|
|
||||||
#[cfg(feature = "tokio-rustls")]
|
|
||||||
use tokio_rustls::rustls::{ClientConfig, OwnedTrustAnchor, RootCertStore, ServerName};
|
|
||||||
#[cfg(feature = "tokio-rustls")]
|
|
||||||
use tokio_rustls::TlsConnector;
|
|
||||||
use tracing::{debug, error, info};
|
|
||||||
|
|
||||||
use crate::common::{Certificate, NoExtension, PrivateKey};
|
use crate::common::NoExtension;
|
||||||
|
#[cfg(feature = "tokio-rustls")]
|
||||||
|
use crate::common::{Certificate, PrivateKey};
|
||||||
pub use crate::connection::Connector;
|
pub use crate::connection::Connector;
|
||||||
use crate::connection::{self, EppConnection};
|
use crate::connection::EppConnection;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::hello::{Greeting, Hello};
|
use crate::hello::{Greeting, Hello};
|
||||||
use crate::request::{Command, CommandWrapper, Extension, Transaction};
|
use crate::request::{Command, CommandWrapper, Extension, Transaction};
|
||||||
|
@ -39,6 +29,7 @@ use crate::xml;
|
||||||
/// use instant_epp::domain::DomainCheck;
|
/// use instant_epp::domain::DomainCheck;
|
||||||
/// use instant_epp::common::NoExtension;
|
/// use instant_epp::common::NoExtension;
|
||||||
///
|
///
|
||||||
|
/// # #[cfg(feature = "tokio-rustls")]
|
||||||
/// # #[tokio::main]
|
/// # #[tokio::main]
|
||||||
/// # async fn main() {
|
/// # async fn main() {
|
||||||
/// // Create an instance of EppClient
|
/// // Create an instance of EppClient
|
||||||
|
@ -62,6 +53,9 @@ use crate::xml;
|
||||||
/// .iter()
|
/// .iter()
|
||||||
/// .for_each(|chk| println!("Domain: {}, Available: {}", chk.inner.id, chk.inner.available));
|
/// .for_each(|chk| println!("Domain: {}, Available: {}", chk.inner.id, chk.inner.available));
|
||||||
/// # }
|
/// # }
|
||||||
|
/// #
|
||||||
|
/// # #[cfg(not(feature = "tokio-rustls"))]
|
||||||
|
/// # fn main() {}
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// The output would look like this:
|
/// The output would look like this:
|
||||||
|
@ -215,13 +209,33 @@ impl<'c, 'e, C, E> Clone for RequestData<'c, 'e, C, E> {
|
||||||
impl<'c, 'e, C, E> Copy for RequestData<'c, 'e, C, E> {}
|
impl<'c, 'e, C, E> Copy for RequestData<'c, 'e, C, E> {}
|
||||||
|
|
||||||
#[cfg(feature = "tokio-rustls")]
|
#[cfg(feature = "tokio-rustls")]
|
||||||
pub struct RustlsConnector {
|
use rustls_connector::RustlsConnector;
|
||||||
|
|
||||||
|
#[cfg(feature = "tokio-rustls")]
|
||||||
|
mod rustls_connector {
|
||||||
|
use std::io;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use tokio::net::lookup_host;
|
||||||
|
use tokio::net::TcpStream;
|
||||||
|
use tokio_rustls::client::TlsStream;
|
||||||
|
use tokio_rustls::rustls::{ClientConfig, OwnedTrustAnchor, RootCertStore, ServerName};
|
||||||
|
use tokio_rustls::TlsConnector;
|
||||||
|
use tracing::info;
|
||||||
|
|
||||||
|
use crate::common::{Certificate, PrivateKey};
|
||||||
|
use crate::connection::{self, Connector};
|
||||||
|
use crate::error::Error;
|
||||||
|
|
||||||
|
pub struct RustlsConnector {
|
||||||
inner: TlsConnector,
|
inner: TlsConnector,
|
||||||
domain: ServerName,
|
domain: ServerName,
|
||||||
server: (String, u16),
|
server: (String, u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RustlsConnector {
|
impl RustlsConnector {
|
||||||
pub async fn new(
|
pub async fn new(
|
||||||
server: (String, u16),
|
server: (String, u16),
|
||||||
identity: Option<(Vec<Certificate>, PrivateKey)>,
|
identity: Option<(Vec<Certificate>, PrivateKey)>,
|
||||||
|
@ -265,11 +279,10 @@ impl RustlsConnector {
|
||||||
server,
|
server,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "tokio-rustls")]
|
#[async_trait]
|
||||||
#[async_trait]
|
impl Connector for RustlsConnector {
|
||||||
impl Connector for RustlsConnector {
|
|
||||||
type Connection = TlsStream<TcpStream>;
|
type Connection = TlsStream<TcpStream>;
|
||||||
|
|
||||||
async fn connect(&self, timeout: Duration) -> Result<Self::Connection, Error> {
|
async fn connect(&self, timeout: Duration) -> Result<Self::Connection, Error> {
|
||||||
|
@ -288,4 +301,5 @@ impl Connector for RustlsConnector {
|
||||||
let future = self.inner.connect(self.domain.clone(), stream);
|
let future = self.inner.connect(self.domain.clone(), stream);
|
||||||
connection::timeout(timeout, future).await
|
connection::timeout(timeout, future).await
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue