Interface Codec<T>

Type Parameters:
T - the application type
All Known Implementing Classes:
PText.TextCodec

public interface Codec<T>
Encodes a key or value to the canonical CBOR item a node embeds and decodes it back (srad/agentspaces-pdt.md §3.1, §3.2). The default of of(Class) is CborCodec.toBytes and fromBytes with the class, so a key hashes and compares by the same bytes every language produces.
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(byte[] bytes)
    The value of one CBOR data item.
    byte[]
    encode(T value)
    The canonical CBOR bytes of a value, exactly one data item.
    static <T> Codec<T>
    of(Class<T> type)
    The canonical codec for a class.
  • Method Details

    • encode

      byte[] encode(T value)
      The canonical CBOR bytes of a value, exactly one data item.
    • decode

      T decode(byte[] bytes)
      The value of one CBOR data item.
    • of

      static <T> Codec<T> of(Class<T> type)
      The canonical codec for a class.