# Design Axioms
- Simplicity.
This means reducing the number of lines of code at the cost of functionality.
- Correctness.
If it is possible to design a simple abstraction that enforces correct usage patterns at compile
time, we prefer that. Compared to `minicbor`, the `Encoder` and `Decoder` types
try to minimize the number of methods that can lead to invalid CBOR encodings or decoding errors.
For example, the `Decoder` exposes `array_visitor`, which allows iterating over the contents of
and array. Note that correctness is not enforced when the required solution is too complex.
For example, `ArrayVisitor` does not ensure that the decoder is in a consistent state if the
`ArrayVisitor` is dropped before reaching the end of the array. `Encoder` also exposes methods
to encode the header of an array, without enforcing that the correct number of elements are
encoded.
- Infallible encoding.
The `Encode` trait does not support returning encoding errors. The only errors returned are those
generated by the underlying `W: Write`.
- User defined decoding errors.
The `Decode` trait has an associated `Error` type, allowing for better user-defined error types.
When deriving `Decode`, an error type is also generated.
- Strict decoding.
Compared to `ciborium` and `minicbor`, which follow the
["robustness principle"](https://en.wikipedia.org/wiki/Robustness_principle), this library is
stricter in what it accepts when impelenting `Decode` with the derive macro. By default,
arrays containing extra elements are rejected, and default values are not used when a field is
missing.
- Use smallest numeric representation when encoding.
Integers and floats are encoded using the smallest possible representation that does not lose
precision. For example, `16u64` is encoded as a `u8`, and `1.0f32` is encoded as a `f16`.