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.
Methods
public abstract void write(ProtoWriter out, T value)
throws IOException | Writes value’s populated fields to out in the protobuf binary wire format. |
public abstract T read(ProtoReader in)
throws IOException | Reads a message from in and returns the populated instance. |
Method details
write
public abstract void write(ProtoWriter out, T value)
throws IOExceptionWrites
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
read
public abstract T read(ProtoReader in)
throws IOExceptionReads 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.