Serializable

This interface represents a type that this is serializable. To implement this interface the user needs to implement two methods, one for serialization and one for deserialization. These methods are used to perform custom (de)serialization and will be called if available. It's up to these methods to call the serializer to perform the (de)serialization. If these methods are available the automatic (de)serialization process will not be performed.

These methods can also be used without actually implementing this interface, i.e. they also work for structs.

Members

Functions

fromData
void fromData(Serializer serializer, Serializer.Data key)

Called by the given serializer when performing custom deserialization.

toData
void toData(Serializer serializer, Serializer.Data key)

Called by the given serializer when performing custom serialization.

Examples

class Foo : Serializable
{
    int a;

    void toData (Serializer serializer, Serializer.Data key)
    {
        serializer.serialize(a, "b");
    }

 void fromData (Serializer serializer, Serializer.Data key)
 {
     a = serializer.deserialize!(int)("b");
 }
}

See Also

isSerializable

Meta