Struct trust_dns_client::client::AsyncClient
source · [−]pub struct AsyncClient { /* private fields */ }
Expand description
A DNS Client implemented over futures-rs.
This Client is generic and capable of wrapping UDP, TCP, and other underlying DNS protocol implementations.
Implementations
sourceimpl AsyncClient
impl AsyncClient
sourcepub async fn new<F, S>(
stream: F,
stream_handle: BufDnsStreamHandle,
signer: Option<Arc<Signer>>
) -> Result<(AsyncClient, DnsExchangeBackground<DnsMultiplexer<S, Signer>, TokioTime>), ProtoError> where
F: Future<Output = Result<S, ProtoError>> + Send + Unpin + 'static,
S: DnsClientStream + 'static + Unpin,
pub async fn new<F, S>(
stream: F,
stream_handle: BufDnsStreamHandle,
signer: Option<Arc<Signer>>
) -> Result<(AsyncClient, DnsExchangeBackground<DnsMultiplexer<S, Signer>, TokioTime>), ProtoError> where
F: Future<Output = Result<S, ProtoError>> + Send + Unpin + 'static,
S: DnsClientStream + 'static + Unpin,
Spawns a new AsyncClient Stream. This uses a default timeout of 5 seconds for all requests.
Arguments
stream
- A stream of bytes that can be used to send/receive DNS messages (see TcpClientStream or UdpClientStream)stream_handle
- The handle for thestream
on which bytes can be sent/received.signer
- An optional signer for requests, needed for Updates with Sig0, otherwise not needed
sourcepub async fn with_timeout<F, S>(
stream: F,
stream_handle: BufDnsStreamHandle,
timeout_duration: Duration,
signer: Option<Arc<Signer>>
) -> Result<(AsyncClient, DnsExchangeBackground<DnsMultiplexer<S, Signer>, TokioTime>), ProtoError> where
F: Future<Output = Result<S, ProtoError>> + 'static + Send + Unpin,
S: DnsClientStream + 'static + Unpin,
pub async fn with_timeout<F, S>(
stream: F,
stream_handle: BufDnsStreamHandle,
timeout_duration: Duration,
signer: Option<Arc<Signer>>
) -> Result<(AsyncClient, DnsExchangeBackground<DnsMultiplexer<S, Signer>, TokioTime>), ProtoError> where
F: Future<Output = Result<S, ProtoError>> + 'static + Send + Unpin,
S: DnsClientStream + 'static + Unpin,
Spawns a new AsyncClient Stream.
Arguments
stream
- A stream of bytes that can be used to send/receive DNS messages (see TcpClientStream or UdpClientStream)timeout_duration
- All requests may fail due to lack of response, this is the time to wait for a response before canceling the request.stream_handle
- The handle for thestream
on which bytes can be sent/received.signer
- An optional signer for requests, needed for Updates with Sig0, otherwise not needed
sourcepub async fn connect<F, S>(
connect_future: F
) -> Result<(AsyncClient, DnsExchangeBackground<S, TokioTime>), ProtoError> where
S: DnsRequestSender,
F: Future<Output = Result<S, ProtoError>> + 'static + Send + Unpin,
pub async fn connect<F, S>(
connect_future: F
) -> Result<(AsyncClient, DnsExchangeBackground<S, TokioTime>), ProtoError> where
S: DnsRequestSender,
F: Future<Output = Result<S, ProtoError>> + 'static + Send + Unpin,
Returns a future, which itself wraps a future which is awaiting connection.
The connect_future should be lazy.
Returns
This returns a tuple of Self a handle to send dns messages and an optional background. The background task must be run on an executor before handle is used, if it is Some. If it is None, then another thread has already run the background.
sourcepub fn enable_edns(&mut self)
pub fn enable_edns(&mut self)
(Re-)enable usage of EDNS for outgoing messages
sourcepub fn disable_edns(&mut self)
pub fn disable_edns(&mut self)
Disable usage of EDNS for outgoing messages
Trait Implementations
sourceimpl Clone for AsyncClient
impl Clone for AsyncClient
sourcefn clone(&self) -> AsyncClient
fn clone(&self) -> AsyncClient
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl DnsHandle for AsyncClient
impl DnsHandle for AsyncClient
type Response = DnsExchangeSend
type Response = DnsExchangeSend
The associated response from the response stream, this should resolve to the Response messages
type Error = ProtoError
type Error = ProtoError
Error of the response, generally this will be ProtoError
sourcefn send<R: Into<DnsRequest> + Unpin + Send + 'static>(
&mut self,
request: R
) -> Self::Response
fn send<R: Into<DnsRequest> + Unpin + Send + 'static>(
&mut self,
request: R
) -> Self::Response
Send a message via the channel in the client Read more
sourcefn is_using_edns(&self) -> bool
fn is_using_edns(&self) -> bool
Allow for disabling EDNS
sourcefn is_verifying_dnssec(&self) -> bool
fn is_verifying_dnssec(&self) -> bool
Only returns true if and only if this DNS handle is validating DNSSec. Read more
Auto Trait Implementations
impl !RefUnwindSafe for AsyncClient
impl Send for AsyncClient
impl Sync for AsyncClient
impl Unpin for AsyncClient
impl !UnwindSafe for AsyncClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more