# serialize

serialize the value

          typedef void* TypeInstanceID;

            int serialize
            TypeInstanceID instance
            char* buffer
            int bufferLen

## Arguments

`instance`

  The value of this type instance will be serialized in the `buffer`. The value of `instance` stays unchanged.

`buffer`

  This is a pointer to an buffer with the size `bufferLen`. If the buffer is big enough the value of `instance` will be stored serialized in this buffer.

`bufferLen`

  This is the size of the `buffer` in bytes.

## Description

The function serializes the value of `instance` into the `buffer` with the size `bufferLen`. If the buffer provided by the caller isn't big enough for the serialized value the `buffer` is not changed and the required size is returned. In the other case the value of `instance` is written as a bytesequence to the front of the buffer and the number of used bytes is returned.

This method is optional. If you want to provide the (de)serialisation functionality you must also implement the `deSerialize` method.

## Return Value

If the buffer is big enough the number of written bytes is returned. In the other case the return value is the number of needed bytes.