Struct dns_mock_server::Server
source · pub struct Server { /* private fields */ }Expand description
A simple mock server for DNS requests.
The intended usage is to create a new instance using Server::default() and add some record
mappings to it. You can then bind a UdpSocket and start the server with Server::start()
in a background task before making requests on the main thread.
Implementations§
source§impl Server
impl Server
sourcepub fn add_records(
&mut self,
name: &str,
records: Vec<IpAddr>
) -> Result<(), ProtoError>
pub fn add_records( &mut self, name: &str, records: Vec<IpAddr> ) -> Result<(), ProtoError>
Adds a mapping from a DNS record to some IP addresses.
Example
let mut server = Server::default();
let records = vec![IpAddr::V4(Ipv4Addr::LOCALHOST)];
server.add_records("example.com", records).expect("Invalid hostname");Trait Implementations§
source§impl RequestHandler for Server
impl RequestHandler for Server
source§fn handle_request<'life0, 'life1, 'async_trait, R>(
&'life0 self,
request: &'life1 Request,
response_handler: R
) -> Pin<Box<dyn Future<Output = ResponseInfo> + Send + 'async_trait>>where
R: 'async_trait + ResponseHandler,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_request<'life0, 'life1, 'async_trait, R>(
&'life0 self,
request: &'life1 Request,
response_handler: R
) -> Pin<Box<dyn Future<Output = ResponseInfo> + Send + 'async_trait>>where
R: 'async_trait + ResponseHandler,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Determines what needs to happen given the type of request, i.e. Query or Update. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnwindSafe for Server
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more