Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.deser.low_level

pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == typeof(null)));
Deserialize null value
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x1F]).describe; // null.bool
typeof(null) value;
assert(deserializeValueImpl!(typeof(null))(data, value) == IonErrorCode.none);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == bool));
Deserialize boolean value
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x11]).describe;
bool value;
assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (isIntegral!T && !is(T == enum));
Deserialize integral value.
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x21, 0x07]).describe;
int valueS;
uint valueU;

assert(deserializeValueImpl(data, valueS) == IonErrorCode.none);
assert(valueS == 7);

assert(deserializeValueImpl(data, valueU) == IonErrorCode.none);
assert(valueU == 7);

data = IonValue([0x31, 0x07]).describe;

assert(deserializeValueImpl(data, valueS) == IonErrorCode.none);
assert(valueS == -7);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T : BigInt!maxSize64, size_t maxSize64)(IonDescribedValue data, ref T value);
Deserialize big integer value.
Examples:
import mir.ion.value;
import mir.ion.exception;
import mir.bignum.integer;

auto data = IonValue([0x31, 0x07]).describe;
BigInt!256 value = void; // 256x64

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value.sign);
assert(value.view.unsigned == 7);
pure nothrow @safe IonErrorCode deserializeValueImpl()(IonDescribedValue data, ref Blob value);
Deserialize Blob value.
Examples:
import mir.deser.ion : deserializeIon;
import mir.lob : Blob;
import mir.ser.ion : serializeIon;

static struct BlobWrapper { Blob blob; }
auto blob = BlobWrapper(Blob([0xF0, 0x00, 0xBA, 0x50]));
auto serdeBlob = serializeIon(blob).deserializeIon!BlobWrapper;
assert(serdeBlob == blob);
pure nothrow @safe IonErrorCode deserializeValueImpl()(IonDescribedValue data, ref Clob value);
Deserialize Clob value.
Examples:
import mir.deser.ion : deserializeIon;
import mir.lob : Clob;
import mir.ser.ion : serializeIon;

static struct ClobWrapper { Clob clob; }
auto clob = ClobWrapper(Clob("abcd"));
auto serdeClob = serializeIon(clob).deserializeIon!ClobWrapper;
assert(serdeClob == clob);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (isFloatingPoint!T);
Deserialize floating point value.

Special deserialisation symbol values

nan"
+inf"
-inf

Examples:
import mir.ion.value;
import mir.ion.exception;
// from ion float
auto data = IonValue([0x44, 0x42, 0xAA, 0x40, 0x00]).describe;
double value;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == 85.125);

// from ion double
data = IonValue([0x48, 0x40, 0x55, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00]).describe;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == 85.125);

// from ion decimal
data = IonValue([0x56, 0x00, 0xcb, 0x80, 0xbc, 0x2d, 0x86]).describe;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == -12332422e75);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T : Decimal!maxW64bitSize, size_t maxW64bitSize)(IonDescribedValue data, ref T value);
Deserialize decimal value.
Examples:
import mir.ion.value;
import mir.ion.exception;
import mir.bignum.decimal;

Decimal!256 value; // 256x64 bits

// from ion decimal
auto data = IonValue([0x56, 0x00, 0xcb, 0x80, 0xbc, 0x2d, 0x86]).describe;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(cast(double)value == -12332422e75);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == Timestamp));

IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (!(hasProxy!T && !hasLikeStruct!T && isFirstOrderSerdeType!T) && is(typeof(Timestamp.init.opCast!T)));
Deserialize timestamp value.
Examples:
import mir.ion.value;
import mir.ion.exception;
import mir.bignum.decimal;

Decimal!256 value; // 256x64 bits

// from ion decimal
auto data = IonValue([0x56, 0x00, 0xcb, 0x80, 0xbc, 0x2d, 0x86]).describe;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(cast(double)value == -12332422e75);
IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (hasProxy!T && !hasLikeStruct!T && isFirstOrderSerdeType!T);
Deserialize struct/class value with proxy.
IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == enum) && !hasProxy!T);
Deserialize enum value.
Examples:
import mir.ion.value;
import mir.ion.exception;
enum E {a, b, c}

// from ion string
auto data = IonValue([0x81, 'b']).describe;
E value;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == E.b);
pure nothrow @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == char));
Deserialize ascii value from ion string.
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x81, 'b']).describe;
char value;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == 'b');
IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == E[], E) && !isSomeChar!E);
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([
    0xbe, 0x91, 0x00, 0x00, 0x21, 0x0c,
    0x00, 0x00, 0x48, 0x43, 0x0c, 0x6b,
    0xf5, 0x26, 0x34, 0x00, 0x00, 0x00,
    0x00]).describe;

double[] value;
assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == [12, 100e13]);
IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == RCArray!E, E) && !isSomeChar!E);
Examples:
import mir.ion.exception;
import mir.ion.value;
import mir.rc.array: RCArray;

auto data = IonValue([
    0xbe, 0x91, 0x00, 0x00, 0x21, 0x0c,
    0x00, 0x00, 0x48, 0x43, 0x0c, 0x6b,
    0xf5, 0x26, 0x34, 0x00, 0x00, 0x00,
    0x00]).describe;

RCArray!(const double) value;
assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value[] == [12, 100e13]);
IonErrorCode deserializeValueImpl(T : SmallArray!(E, maxLength), E, size_t maxLength)(IonDescribedValue data, out T value);
IonErrorCode deserializeValueImpl(T : E[N], E, size_t N)(IonDescribedValue data, out T value);
Examples:
import mir.ion.value;
import mir.ion.exception;
import mir.small_array;

auto data = IonValue([
    0xbe, 0x91, 0x00, 0x00, 0x21, 0x0c,
    0x00, 0x00, 0x48, 0x43, 0x0c, 0x6b,
    0xf5, 0x26, 0x34, 0x00, 0x00, 0x00,
    0x00]).describe;

SmallArray!(double, 3) value;
assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == [12, 100e13]);