bacnet-bip-codec
The BVLL codec of rusty-bacnet:
the wire format of BACnet/IP (Annex J of ASHRAE 135) at the crate root and
of BACnet/IPv6 (Annex U) in its ipv6 module, and nothing above it.
Sockets, BBMD forwarding and foreign-device registration belong to the
layer that uses it, such as bacnet-bip-core.
#![no_std], no allocator and no dependencies in the default build.- The twelve B/IP messages and the twelve B/IPv6 ones, as
BvllandBvll6values that borrow their NPDU or table from the datagram. - Decoding is strict about shape (BVLC type, a Length field equal to the datagram, a payload the function's layout allows) and lenient about values; encoding refuses what the Length field can't state and a BVLC-Result with an undefined code.
BvlcFunction,BvlcResultCodeand their B/IPv6 counterparts are open sets: a constant for each code the standard defines, andfrom_rawfor any other, so a decoder can report a code it doesn't know.- BDT and FDT entries, read through iterators straight from the wire.
- A B/IP address is a plain
SocketAddrV4, since all of it travels; a B/IPv6 address is aBip6Address, which keeps the 18 octets that travel and none of aSocketAddrV6's flow label or scope ID.
Features
None is on by default, and none needs std. Each adds a BvllSink, which
both encoders write to:
alloc: forVec<u8>.bytes: forbytes::BytesMut; impliesalloc.heapless: forheapless::Vec<u8, N>.
Example
use ;
use ;
// Encode an Original-Broadcast-NPDU into caller storage.
let npdu = ;
let mut wire = ;
let length = OriginalBroadcastNpdu.encode_into.unwrap;
assert_eq!;
assert_eq!;
// A Forwarded-NPDU carries its originator's address.
let wire = ;
let origin = new;
assert_eq!;
// A function the standard doesn't define still has a frame, so a
// receiver can see what arrived before refusing it.
let frame = decode.unwrap;
assert_eq!;
assert!;
assert!;
License
MIT