#embedded-nal #embedded-devices #linux-networking #networking-stack #embedded-hal #standard #embedded-nal-async

std-embedded-nal

Implementation of the embedded-nal traits for large devices that support the standard library

9 unstable releases (3 breaking)

0.3.0 Jun 5, 2024
0.2.0 Oct 25, 2023
0.1.3 Jul 25, 2022
0.1.2 Nov 1, 2021
0.0.1 Sep 2, 2020

#458 in Embedded development

Download history 38/week @ 2024-07-20 337/week @ 2024-07-27 202/week @ 2024-08-03 308/week @ 2024-08-10 255/week @ 2024-08-17 362/week @ 2024-08-24 1019/week @ 2024-08-31 1260/week @ 2024-09-07 625/week @ 2024-09-14 1290/week @ 2024-09-21 655/week @ 2024-09-28 515/week @ 2024-10-05 471/week @ 2024-10-12 387/week @ 2024-10-19 398/week @ 2024-10-26 769/week @ 2024-11-02

2,171 downloads per month
Used in 3 crates

MIT/Apache

23KB
412 lines

std-embedded-nal

This crate implements the embedded-nal network traits for operating systems that support the standard library's network. .

In that, it is to embedded-nal what linux-embedded-hal is to embedded-hal: A way to use libraries written for the bare-metal embedded world on Linux. (Just that network interfaces are better standardized than hardware access, so it should work on any system).

Usage

As the operating system's network stack is always available, it can be instanciated and used at any time without need for synchronization, roughly like this:

use embedded_nal::nb::block;
use std_embedded_nal::Stack;
use embedded_nal::UdpClient;

let message = [0x50, 0x01, 0x00, 0x00];

let mut stack = Stack::default();
let mut socket = stack.socket()?;
block!(stack.connect(&mut socket, "127.0.0.1:5683".parse()?)?);
block!(stack.send(&mut socket, &message)?);

See the CoAP and HTTP examples for full and working versions.

Performance, non-blocking and async

When using the regular embedded-nal APIs, the client main examples run use nb::block!, which means that there is busy looping until an event arrives (which is bad in clients and terrible in servers).

The general expectation with these APIs based on nb is that users would know when to try again; the UNIX version of the coapclient example illustrates how that would probably be done. (The setup around mio and this library is relatively complex; embedded implementations might get away with less code there.)

On nightly, and gated by the async feature, the asynchronous implementations of the embedded-nal-async crate are available.

Maturity

This crate contains minimal working implementations the traits currently in embedded-nal.

Minimum Supported Rust Version

This crate is build-tested on stable Rust 1.60.0. That is largely following the embedded-nal MSRV. It might compile with older versions but that may change at any time.

Dependencies

~0.2–9MB
~94K SLoC