Hcs.Codec.Identity_codec

hcs · API reference

Pass-through codec for raw binary data.

Use this when the application already owns a Cstruct.t and no additional serialization is needed.

type 'a encoder = 'a -> Cstruct.t

Encoder for values of type 'a.

type 'a decoder = Cstruct.t -> ('a, string) result

Decoder for values of type 'a.

val content_type : string

HTTP Content-Type emitted for encoded values.

val encode : 'a encoder -> 'a -> (Cstruct.t, string) result

Encode a value to bytes.

val decode : 'a decoder -> Cstruct.t -> ('a, string) result

Decode bytes into a value.

val encode_stream : 'a encoder -> 'a -> Cstruct.t Seq.t option

Optional streaming encoder for large values. Return None when unsupported.

val decode_stream : 'a decoder -> Cstruct.t Seq.t -> ('a, string) result option

Optional streaming decoder for large values. Return None when unsupported.