Crate cbored

Source
Expand description

CBOR exact reader and writer

use cbored::Reader;
let mut reader = Reader::new(&[0x80]);
let array = reader.array().expect("valid array");
assert_eq!(array.len(), 0);
use cbored::{Writer, StructureLength, Positive};
let mut writer = Writer::new();
writer.array_build(StructureLength::Indefinite, |writer| {
    writer.positive(Positive::canonical(10));
})

Modules§

state
CBOR State
tagged
A non exhaustive implementation of the most common tagged CBOR extension
validate
A CBOR validator for raw data

Structs§

Array
CBOR Array with references to elements
ArrayBuilder
CBOR Array builder, when constructing
ArrayOwned
CBOR Array with owned elements
Byte
CBOR Byte value
BytesData
CBOR Bytestream reference to a chunk of byte
BytesDataOwned
CBOR Bytestream owned chunk of byte
CborDataOf
A Validated CBOR slice of data containing the type T
CborSlice
A Validated CBOR slice of data
CborSliceOf
DecodeError
Possible decode error when decoding an element
Map
CBOR Map with references to keys and values
MapOwned
CBOR Map with owned keys and values
Negative
CBOR Negative value
Positive
CBOR Positive value
Reader
CBOR Data structure to read CBOR elements from a slice of byte
Tag
CBOR Tag with reference to the tagged element
TagOwned
CBOR Tag with owned tagged element
TagValue
CBOR Tag Value in a Tag
TextData
CBOR Text chunk with reference to the chunk of utf8 sequence
TextDataOwned
CBOR Text chunk with owned chunk of utf8 sequence
Writer
CBOR Data structure to write CBOR elements to a growing byte vector

Enums§

Bytes
CBOR Bytestream (indefinite and definite) with reference to the bytes
BytesOwned
CBOR Bytestream (indefinite and definite) with owned bytes
Constant
CBOR constants (False/True/Null/Undefined)
Data
One CBOR Data element with references to the data
DataOwned
One CBOR Data element with owned data
DecodeErrorKind
Possible errors when decoding an element
Float
CBOR Float (FP16, FP32, FP64)
ReaderError
Possible error when reading CBOR from a data stream
Scalar
Union type of CBOR Positive or Negative value
StructureLength
Text
CBOR Text (UTF-8) (indefinite and definite) with reference to text chunk
TextOwned
CBOR Text (UTF-8) (indefinite and definite) with owned text chunk
Type
One of CBOR possible type

Traits§

Decode
Generic Decode trait to read an element T from the CBOR reader
Encode
Generic Encode trait to write an element T into the CBOR writer

Functions§

decode_from_bytes
Try to decode bytes into T from its CBOR bytes representation
decode_vec
Decode zero to many Ts in an array
encode_to_bytes
Encode an encodable type T into its CBOR bytes representation
encode_vec
Encode a slice of Ts, as a CBOR array of definite length and each element written with the encode method for each T value sequentially

Derive Macros§

CborRepr