serializeIon

Ion serialization for custom outputt range.

  1. immutable(ubyte)[] serializeIon(T value, int serdeTarget)
  2. void serializeIon(Appender appender, T value, int serdeTarget)
    void
    serializeIon
    (
    Appender
    T
    )
    (
    scope ref Appender appender
    ,
    auto ref T value
    ,
    int serdeTarget = SerdeTarget.ion
    )
    if (
    isOutputRange!(Appender, const(ubyte)[]) &&
    !is(T == SerdeTarget)
    )

Examples

import mir.test;
import mir.appender: scopedBuffer;

static struct S
{
    string s;
    double aaaa;
    int bbbb;
}

auto s = S("str", 1.23, 123);

static immutable ubyte[] data = [
    0xe0, 0x01, 0x00, 0xea, 0xee, 0x92, 0x81, 0x83,
    0xde, 0x8e, 0x87, 0xbc, 0x81, 0x73, 0x84, 0x61,
    0x61, 0x61, 0x61, 0x84, 0x62, 0x62, 0x62, 0x62,
    0xde, 0x92, 0x8a, 0x83, 0x73, 0x74, 0x72, 0x8b,
    0x48, 0x3f, 0xf3, 0xae, 0x14, 0x7a, 0xe1, 0x47,
    0xae, 0x8c, 0x21, 0x7b,
];

auto buffer = scopedBuffer!ubyte;
serializeIon(buffer, s);
buffer.data.should == data;

Meta