~nickbp/originz

ref: d94f181c5fbfdf0f62b40ea46d3f301f4ec681e5 originz/src/client/mod.rs -rw-r--r-- 1.1 KiB
d94f181cNick Parker Backport current benchmark to older code 1 year, 8 months ago
                                                                                
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
#![deny(warnings)]

use anyhow::Result;
use async_trait::async_trait;
use bytes::BytesMut;

use crate::fbs::dns_message_generated::Message;

#[async_trait]
pub trait DnsClient {
    /// Converts the provided request to an encoded representation that can be passed to `query()`.
    /// This separate call allows reusing the same backing flatbuffer buffer for both the request Message and the response Message.
    fn encode(&self, request: &Message<'_>, request_buffer: &mut BytesMut) -> Result<()>;

    /// Runs a query for the provided encoded request, then returns the response.
    /// The provided `response_fbb` is used as backing storage for the response.
    async fn query<'response>(
        &mut self,
        request_buffer: &mut BytesMut,
        response_fbb: &'response mut flatbuffers::FlatBufferBuilder<'_>,
    ) -> Result<Option<Message<'response>>>;
}

/// Implements hyper HTTP library support for querying a configured external DNS server.
/// Avoids using the OS resolver because that might loop back to us.
pub mod hyper;

/// Client: DNS over HTTPS
pub mod https;
/// Client: TCP (fallback for UDP)
pub mod tcp;
/// Client: UDP
pub mod udp;