hadris-fixed
Fixed-capacity byte, UTF-8, and UTF-16 values for no_std applications.
Storage is inline, so the core API needs neither a global allocator nor the
standard library.
Use this crate for bounded on-disk names, labels, and protocol fields. Raw bytes and validated text are distinct types, so safe text APIs cannot be constructed from invalid UTF-8.
Types
| Type | Purpose |
|---|---|
FixedBytes<N> |
Arbitrary initialized bytes with capacity N |
FixedStr<N> |
Valid UTF-8 with a fixed byte capacity |
FixedUtf16Le<N> |
Little-endian UTF-16 code units |
FixedUtf16Be<N> |
Big-endian UTF-16 code units |
Example
use ;
let mut bytes = new;
bytes.try_push_slice?;
assert_eq!;
let mut name = new;
name.try_push_str?;
name.try_push?;
name.try_push_str?;
assert_eq!;
# Ok::
The fallible try_* methods return CapacityError; convenience methods
without try_ panic when capacity is exceeded.
Features
| Feature | Default | Purpose |
|---|---|---|
alloc |
No | Conversions and conveniences that return allocated values |
bytemuck |
No | Byte-safe trait implementations for compatible fixed types |
Documentation
License
Licensed under the MIT license.