Expand description
Traits for Rust representations of Protobuf string, bytes, repeated, and map fields.
In order to represent string, bytes, repeated, and map fields in Rust, multi-element
containers are needed. To ensure flexibility, micropb interfaces with containers using traits
from this module rather than hard-coded types. This allows compatibility with different
container implementations. For example, no-std users can use fixed-capacity containers from
heapless or arrayvec, and alloc users can use dynamic-capacity containers from the
standard library.
For convenience, container trait implementations on existing types are provided in this module, gated by feature flags.
- For
heapless,PbString,PbBytes,PbVec, andPbMapare implemented onheapless::String,heapless::Vec, andheapless::IndexMap. - For
arrayvec,PbString,PbBytes, andPbVecare implemented onarrayvec::ArrayStringandarrayvec::ArrayVec. - For
alloc,PbString,PbBytes,PbVec, andPbMapare implemented onString,Vec, andBTreeMap. Ifstdis enabled,PbMapis also implemented forHashMap.
It is also possible to use other types as containers if the container traits are implemented.
Traitsยง
- PbBytes
- Container that stores a sequence of arbitrary bytes. Represents Protobuf
bytesfield. - PbMap
- Map that stores key-value pairs. Represents Protobuf
mapfield. - PbString
- Container that stores a string. Represents Protobuf
stringfield. - PbVec
- Generic vector that stores multiple elements. Represents repeated field.