itsdns

Crates.ioitsdns
lib.rsitsdns
version0.1.0
sourcesrc
created_at2023-01-30 18:47:17.30099
updated_at2023-01-30 18:47:17.30099
descriptionLight weight DNS client based on embedded-nal-async
homepage
repositoryhttps://github.com/lulf/itsdns
max_upload_size
id772024
size51,407
Ulf Lilleengen (lulf)

documentation

README

itsdns

CI crates.io docs.rs

It's always DNS.

A light weight (no_std and no_alloc) lightweight DNS client that you can use with any UDP stack implemented by embedded-nal-async. It also implements the DNS traits from embedded-nal-async.

example

#![feature(async_fn_in_trait)]
#![allow(incomplete_features)]

use embedded_nal_async::SocketAddr;
use std::str::FromStr;

use itsdns::*;

#[tokio::main]
async fn main() {
    let nameserver: SocketAddr = SocketAddr::from_str("8.8.8.8:53").unwrap();
    let stack = std_embedded_nal_async::Stack::default();
    let client = ItsDns::new(stack, nameserver);

    let host = "example.com";
    println!("Resolving {}...", host);
    let ip = client
        .get_host_by_name(host, embedded_nal_async::AddrType::IPv4)
        .await
        .unwrap();

    println!("Resolved {} to {}", host, ip);
}
Commit count: 20

cargo fmt