geod24.Serialization

Serialization-related utilities

When passing instances accross threads, LocalRest often cannot use the provided instance itself, as it would require it to be either shared, a value type, or immutable. The term instance here is used to mean an instance of a type, that is either passed as parameter, and used as a return value.

Instead, we support serializing the parameter to one of three types: immutable(void)[], immutable(ubyte)[], or string. The first two are regular serialized target, and string can be used for JSON, XML, etc.

A serializer can be a template or an aggregate, or even a function returning an aggregate. No limitation is put on the type itself, only on what operations should be supported.

For a type T to be a valid serializer, it should support the following actions: - T.serialize() should compile when passed on parameter. - This one parameter can be any type that is either a parameter or a return value of API's methods. This is not checked explicitly, but will lead to compilation error in LocalRest if not followed. - T.serialize(param) should return an one of string, immutable(void)[], immutable(ubyte)[] - T.deserialize!QT is a template function that returns an instance of type QT (QT is potentially qualified, e.g. const). - T.deserialize!!T() should accept one runtime non-default parameter, of the type returned by T.serialize.

The default implementation is the VibeJSONSerializer. Other utilities in this module are used to facilitate development and diagnostics.

Members

Functions

serializerInvalidReason
string serializerInvalidReason()

Utility function to check if a serializer conforms to the requirements

Templates

SerializedT
template SerializedT(alias S)
VibeJSONSerializer
template VibeJSONSerializer()

Serialize arbitrary data to / from JSON

Unions

SerializedData
union SerializedData

Type-erasing wrapper to handle serialized data

Meta

Authors

Mathias 'Geod24' Lang

License

MIT (See LICENSE.txt)