cratestack-codec-cbor
CBOR codec implementation for CrateStack HTTP transport.
Overview
cratestack-codec-cbor implements the CoolCodec trait for CBOR (Concise Binary Object Representation) encoding/decoding.
Installation
[]
= "0.2"
Usage
use CborCodec;
use CoolCodec;
let codec = CborCodec;
// Encode
let bytes = codec.encode?;
// Decode
let value: MyStruct = codec.decode?;
// Content type
assert_eq!;
Codec Trait
Implements CoolCodec from cratestack-core:
Transport Integration
Use with generated Axum routes:
use CborCodec;
let router = model_router;
Or with the Rust client:
use ;
let client = new;
CBOR Sequence
For streaming responses, use application/cbor-seq:
use CborCodec;
// Encode sequence
let mut bytes = Vecnew;
for item in items
// Decode sequence
let items: = codec.decode_sequence?;
See Also
- Transport Architecture
cratestack-codec-json- JSON codec
License
MIT