std-embedded-nal 0.4.0

Implementation of the `embedded-nal` traits for large devices that support the standard library
Documentation
//! A brutally oversimplified HTTP client that GETs / from localhost:80

use embedded_nal::nb::block;
use embedded_nal::{Dns, TcpClientStack};

fn run<S, E, DnsError>(stack: &mut S) -> Result<(), E>
where
    E: core::fmt::Debug, // Might go away when MSRV goes up to 1.49, see https://github.com/rust-lang/rust/issues/80821
    DnsError: core::fmt::Debug,
    S: TcpClientStack<Error = E> + Dns<Error = DnsError>,
{
    let target = core::net::SocketAddr::new(
        block!(stack.get_host_by_name("localhost", embedded_nal::AddrType::IPv6)).unwrap(),
        80,
    );

    let mut sock = stack.socket()?;
    block!(stack.connect(&mut sock, target))?;
    block!(stack.send(&mut sock, b"GET / HTTP/1.0\r\nHostname: localhost\r\n\r\n"))?;

    let mut respbuf = [0; 1500];
    let resplen = block!(stack.receive(&mut sock, &mut respbuf))?;
    let response = &respbuf[..resplen];

    println!("Response: {}", String::from_utf8_lossy(response));

    Ok(())
}

fn main() {
    let mut stack = std_embedded_nal::Stack::default();

    run(&mut stack).expect("Error running the main program")
}