SerializationCoder

Serializes structs and static arrays using a MixedRadixCoder. Consults types' `.max' property to obtain cardinality.

template SerializationCoder (
alias Coder
S
) {}

Members

Functions

deserialize
S deserialize(E encoded)
Undocumented in source. Be warned that the author may not have intended to support it.
serialize
E serialize(S s)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

static struct WithMax(T, T max_)
{
	T value;
	alias value this;
	enum T max = max_;
}

enum E { a, b, c }
alias D6 = WithMax!(uint, 6);

static struct S
{
	ubyte a;
	bool b;
	E[3] e;
	D6 d;
}

alias Coder = SerializationCoder!(MixedRadixCoder!(uint, ulong, true), S);
auto s = S(1, true, [E.a, E.b, E.c], D6(4));
assert(Coder.deserialize(Coder.serialize(s)) == s);

Meta