Fix compilation with --no-default-features

This commit is contained in:
Dirkjan Ochtman 2023-08-02 15:30:52 +02:00
parent c1b118f378
commit ed73ff546f
2 changed files with 100 additions and 82 deletions

View File

@ -34,6 +34,10 @@ jobs:
with:
command: test
args: --all-features
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features
lint:
runs-on: ubuntu-latest

View File

@ -1,22 +1,12 @@
use std::io;
use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait;
#[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 tracing::{debug, error};
use crate::common::{Certificate, NoExtension, PrivateKey};
use crate::common::NoExtension;
#[cfg(feature = "tokio-rustls")]
use crate::common::{Certificate, PrivateKey};
pub use crate::connection::Connector;
use crate::connection::{self, EppConnection};
use crate::connection::EppConnection;
use crate::error::Error;
use crate::hello::{Greeting, Hello};
use crate::request::{Command, CommandWrapper, Extension, Transaction};
@ -39,6 +29,7 @@ use crate::xml;
/// use instant_epp::domain::DomainCheck;
/// use instant_epp::common::NoExtension;
///
/// # #[cfg(feature = "tokio-rustls")]
/// # #[tokio::main]
/// # async fn main() {
/// // Create an instance of EppClient
@ -62,6 +53,9 @@ use crate::xml;
/// .iter()
/// .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:
@ -215,6 +209,26 @@ impl<'c, 'e, C, E> Clone for RequestData<'c, 'e, C, E> {
impl<'c, 'e, C, E> Copy for RequestData<'c, 'e, C, E> {}
#[cfg(feature = "tokio-rustls")]
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,
domain: ServerName,
@ -267,7 +281,6 @@ impl RustlsConnector {
}
}
#[cfg(feature = "tokio-rustls")]
#[async_trait]
impl Connector for RustlsConnector {
type Connection = TlsStream<TcpStream>;
@ -289,3 +302,4 @@ impl Connector for RustlsConnector {
connection::timeout(timeout, future).await
}
}
}