Expand description
Compile-time serialization helpers (const fn, panic on overflow).
Inside const evaluation a panic is a compile error, which turns these
into checked builders for constant CBOR items:
use const_cbor::encode::consts;
const HEARTBEAT: ([u8; 3], usize) = {
let mut buf = [0u8; 3];
let n = consts::put_u64(&mut buf, 0);
(buf, n)
};
assert_eq!(&HEARTBEAT.0[..HEARTBEAT.1], &[0x00]);Functionsยง
- chunk_
len - Encoded length of a string/bytes item with
payload_lencontent bytes. - i64_len
- Preferred encoded length of signed integer
v. - put_i64
- Writes signed integer
vintobuf; returns bytes written. - put_u64
- Writes unsigned integer
vintobuf; returns bytes written. - uint_
len - Preferred encoded length of unsigned integer
v.