SerializationCoder

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

Members

Functions

cardinality
E cardinality()
Undocumented in source. Be warned that the author may not have intended to support it.
deserialize
S deserialize(E encoded)
Undocumented in source. Be warned that the author may not have intended to support it.
maxValue
E maxValue()
Undocumented in source. Be warned that the author may not have intended to support it.
minValue
E minValue()
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));
auto encoded = Coder.serialize(s);
assert(Coder.deserialize(encoded) == s);
assert(Coder.minValue() <= encoded && encoded <= Coder.maxValue());

Meta