diff --git a/client/src/lib.rs b/client/src/lib.rs index a26f466..c358d4c 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,11 +1,13 @@ use mtp_codec::{CommunicationValue, DataType, DataValue, PROTOCOL_VERSION, Version}; use mtp_common::CommunicationError; -use mtp_transport::{Policy, Receiver, Sender}; +use mtp_transport::Policy; #[cfg(feature = "crypto")] use tokio::time::Duration; pub use MTPClient as Client; pub use MTPConnection as Connection; +pub use mtp_transport::Receiver; +pub use mtp_transport::Sender; #[cfg(feature = "crypto")] fn unexpected_response_type_error( diff --git a/host/src/lib.rs b/host/src/lib.rs index c7be550..3573771 100644 --- a/host/src/lib.rs +++ b/host/src/lib.rs @@ -53,6 +53,8 @@ pub struct HostConfig { pub tls_fullchain: Vec, pub tls_key: Vec, + pub policy: Policy, + #[cfg(feature = "crypto")] pub authentication_policy: AuthenticationPolicy, #[cfg(feature = "crypto")] @@ -72,6 +74,7 @@ impl HostConfig { port, tls_fullchain, tls_key, + policy: Policy::default(), #[cfg(feature = "crypto")] authentication_policy: AuthenticationPolicy::Unauthenticated, #[cfg(feature = "crypto")] @@ -92,6 +95,11 @@ impl HostConfig { } } + pub fn with_policy(mut self, policy: Policy) -> Self { + self.policy = policy; + self + } + #[cfg(feature = "crypto")] pub fn with_authentication( mut self, @@ -190,7 +198,7 @@ impl MTPHost { config.port, config.tls_fullchain.clone(), config.tls_key.clone(), - Policy::default(), + config.policy, ) .await?;