Module std.encoding.cbor
CBOR (RFC 8949) encoding of any data value.
import std.encoding.cbor;
type Point { x: i64; y: i64; }
fn main() {
let data = cbor.encode(Point { x: 1, y: 2 });
match cbor.decode<Point>(data) {
.Ok(p) => println(p.x + p.y), // 3
.Err(e) => println(e),
}
}
#[wire] records and enums encode by their @N tags; other records by
field name.
Contents
Functions
Function encode
pub fn encode<T: Serializable>(value: T) -> bytes
Encode any data value as CBOR bytes. Records encode as objects keyed by field name in declaration order.