# Interface ProtoCodec<T>

public interface ProtoCodec<T>

Per-class encoder / decoder for a `@ProtoMessage` type. The Codename One Maven plugin emits one `<Type>ProtoCodec` per `@ProtoMessage` class at build time and registers it with `ProtoCodecs` so gRPC clients can locate codecs for nested message types by class without reflection.

Implementations must be stateless -- the same codec instance is shared across concurrent requests.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `read(ProtoReader in)`
  Reads a message from `in` and returns the populated instance.
  `void`
  `write(ProtoWriter out, T value)`
  Writes `value`'s populated fields to `out` in the protobuf binary wire format.

- ## Method Details

  - ### write

    void write(ProtoWriter out, T value) throws IOException
    Writes `value`'s populated fields to `out` in the protobuf binary wire format. Does not write a length prefix; callers that need length-delimited framing (such as nested messages or gRPC payload framing) handle that one layer up.
    Throws:
      `IOException`

  - ### read

    T read(ProtoReader in) throws IOException
    Reads a message from `in` and returns the populated instance. `in` is expected to be positioned at the start of the message body (no length prefix); callers wrap a slice when reading nested messages.
    Throws:
      `IOException`