Enum member isPolicySerializable
Checks if a given policy supports custom serialization for a given type.
A class or struct type is custom serializable according to a policy if
the policy defines a pair of toRepresentation
/
fromRepresentation
functions. Any class or struct type that has this trait for the policy supplied to
serializeWithPolicy
will be serialized by using the return value of the
policy toRepresentation
function instead of the original value.
This trait has precedence over isCustomSerializable
,
isISOExtStringSerializable
and
isStringSerializable
.
Declaration
enum isPolicySerializable(alias Policy, T) = is(typeof(Policy!T .toRepresentation(T .init))) && is(typeof(Policy!T .fromRepresentation(Policy!T .toRepresentation(T .init))) == T);
See Also
vibe.data.serialization.serializeWithPolicy
Example
import std .conv;
// represented as a string when serialized
static struct S {
int value;
// dummy example implementations
string toString() const { return value .to!string(); }
static S fromString(string s) { return S(s .to!int()); }
}
static assert(isStringSerializable!S);
Authors
Sönke Ludwig
Copyright
© 2013-2014 rejectedsoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.