encodeTo method

  1. @override
void encodeTo(
  1. T value,
  2. Output output
)
override

Convert self to a slice and append it to the destination.

Implementation

@override
void encodeTo(final T value, final Output output) {
  // Encode to temporary buffer to get length
  final temp = ByteOutput();
  inner.encodeTo(value, temp);
  final bytes = temp.toBytes();

  // Write length prefix
  CompactCodec.codec.encodeTo(bytes.length, output);

  // Write the actual bytes
  output.write(bytes);
}