vibe.d beta banner
get vibe.d

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.


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


import std.conv;

// represented as a string when serialized
static struct S {
	int value;

	// dummy example implementations
	string toString() const { return!string(); }
	static S fromString(string s) { return S(!int()); }

static assert(isStringSerializable!S);

Sönke Ludwig


© 2013-2014 rejectedsoftware e.K.


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.