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.ser.interfaces
The module can be used for scripting languages to register a universal type serializer in the type system.
- interface
ISerializer
; - Unified serializer interface.ISerializer can be used in serialize method instead of generic serilizer.
struct S { void serialize(ISerializer serializer) const @safe ...
- abstract pure scope @safe void
putStringPart
(scope const(char)[]value
); - Puts string part. The implementation allows to split string unicode points.
- abstract pure scope @safe void
stringEnd
(size_tstate
); - abstract pure scope @safe size_t
structBegin
(size_tlength
= size_t.max); - abstract pure scope @safe void
structEnd
(size_tstate
); - abstract pure scope @safe size_t
listBegin
(size_tlength
= size_t.max); - abstract pure scope @safe void
listEnd
(size_tstate
); - abstract pure scope @safe size_t
sexpBegin
(size_tlength
= size_t.max); - abstract pure scope @safe void
sexpEnd
(size_tstate
); - abstract pure scope @safe void
putSymbol
(scope const char[]symbol
); - abstract pure scope @safe size_t
annotationsBegin
(); - abstract pure scope @safe void
putAnnotation
(scope const(char)[]annotation
); - abstract pure scope @safe void
annotationsEnd
(size_tstate
); - abstract pure scope @safe size_t
annotationWrapperBegin
(); - abstract pure scope @safe void
annotationWrapperEnd
(size_tstate
); - abstract pure scope @safe void
nextTopLevelValue
(); - abstract pure scope @safe void
putKey
(scope const char[]key
); - final pure scope @safe void
putValue
(ubytevalue
); - final pure scope @safe void
putValue
(ushortvalue
); - final pure scope @safe void
putValue
(uintvalue
); - final pure scope @safe void
putValue
(bytevalue
); - final pure scope @safe void
putValue
(shortvalue
); - final pure scope @safe void
putValue
(intvalue
); - abstract pure scope @safe void
putValue
(longvalue
); - abstract pure scope @safe void
putValue
(ulongvalue
); - abstract pure scope @safe void
putValue
(floatvalue
); - abstract pure scope @safe void
putValue
(doublevalue
); - abstract pure scope @safe void
putValue
(realvalue
); - abstract pure scope @safe void
putValue
(BigIntView!(const(ubyte), WordEndian.big)value
); - abstract pure scope @safe void
putValue
(const ref Decimal!256value
); - abstract pure scope @safe void
putValue
(typeof(null));
abstract pure scope @safe voidputNull
(IonTypeCodecode
); - abstract pure scope @safe void
putValue
(boolb
); - abstract pure scope @safe void
putValue
(scope const char[]value
); - abstract pure scope @safe void
putValue
(Clobvalue
); - abstract pure scope @safe void
putValue
(Blobvalue
); - abstract pure scope @safe void
putValue
(Timestampvalue
); - abstract pure scope @safe void
elemBegin
(); - abstract pure scope @safe void
sexpElemBegin
(); - abstract const pure nothrow @property scope @safe int
serdeTarget
();
- class
SerializerWrapper
(S): ISerializer; - Serializer interface wrapper for common serializers.Examples:
static struct Wrapper(T) { T value; void serialize(ISerializer serializer) const @safe { import mir.ser: serializeValue; serializeValue(serializer, value); } } static auto wrap(T)(T value) { return Wrapper!T(value); } import mir.ion.conv; import mir.ser.ion; import mir.ser.json; import mir.ser.text; import mir.ion.stream; import std.datetime.date; assert(wrap(Date(1234, 5, 6)).serializeJson == `"1234-05-06"`); assert(wrap(Date(1234, 5, 6)).serializeText == `1234-05-06`); assert(wrap(Date(1234, 5, 6)).serializeIon.ion2text == `1234-05-06`); immutable(ushort)[] imdata = [10, 20, 30]; assert(wrap(imdata).serializeIon.ion2text == `[10,20,30]`); const ubyte[] data = [0xe0, 0x01, 0x00, 0xea, 0xe9, 0x81, 0x83, 0xd6, 0x87, 0xb4, 0x81, 0x61, 0x81, 0x62, 0xd6, 0x8a, 0x21, 0x01, 0x8b, 0x21, 0x02]; auto json = wrap(data.IonValueStream).serializeJson; assert(json == `{"a":1,"b":2}`);
- pure nothrow @nogc @trusted this(return ref S
serializer
);
Copyright © 2016-2022 by Ilya Yaroshenko | Page generated by
Ddoc on Thu Mar 10 07:43:26 2022