Function binaryEncoder

A helper function for constructing a [BinaryEncoder] with inferred template arguments.

auto binaryEncoder(ORangeT) (
  ORangeT oRange
);

Example

writeBoolean

import std.array : appender;
import avro.codec.bufferedoutputrange : bufferedOutputRange;

// Here we write into an array, but a file or other range can work.
ubyte[] data;

// Demonstrating the use of a buffered ouput range with the binary encoder.
auto encoder = binaryEncoder(bufferedOutputRange!ubyte(appender(&data)));

with (encoder) {
  writeBoolean(true);
  assert(data == []);
  flush();
  assert(data == [1]);
  writeBoolean(false);
  flush();
  assert(data == [1, 0]);
}