Fixed-width byte codecs #
ByteCodec F is a fixed-width byte encoding of F with a decoder that succeeds on every
encoding. Its single law, ofBytes?_toBytes, makes toBytes injective, and from it the
protocol-facing classes follow for free: HasSize F UInt8, Serialize F ByteArray with
Serialize.IsInjective, DeserializeOption, and Serde, together with the same for
Vector UInt8 (width F).
The encoding is a property of the value, not of the carrier: two carriers of the same field
must give the same bytes for the same element. Scalar fields derive their codec from
CanonicalNat (ByteCodec.ofCanonicalNat, in CompPoly.Data.Bytes.CanonicalNat); composite
types such as extensions and degree-bounded polynomials concatenate the codecs of their parts.
@[simp]
@[simp]
@[simp]
Derived protocol interfaces #
@[instance_reducible]
instance
CompPoly.ByteCodec.instIsInjectiveVectorUInt8Width
{F : Type u}
[ByteCodec F]
:
Serialize.IsInjective F (Vector UInt8 (width F))
@[instance_reducible]
instance
CompPoly.ByteCodec.instDeserializeOptionVectorUInt8Width
{F : Type u}
[ByteCodec F]
:
DeserializeOption F (Vector UInt8 (width F))
@[simp]
@[simp]