Cbf

object Cbf

Functions

Link copied to clipboard
inline fun <C : MutableCollection<Any?>> addCollectionCreator(noinline creator: (size: Int) -> C)

Adds a way to create a specific MutableCollection type when using the built-in collection serializer.

Link copied to clipboard
inline fun <M : MutableMap<Any?, Any?>> addMapCreator(noinline creator: (size: Int) -> M)

Adds a way to create a specific MutableMap type when using the built-in map serializer.

Link copied to clipboard
fun addOrdinalEnums(vararg classes: KClass<out Enum<*>>)

Configures which Enum types should be serialized by their ordinal value instead of their name, when using the built-in enum serializers.

Link copied to clipboard
inline fun <T : Any> copy(value: T?): T?

Creates a deep copy of value.

fun <T : Any> copy(type: KType, value: T?): T?

Creates a deep copy of value of the type T (type).

Link copied to clipboard
inline fun <T : Any> getSerializer(): BinarySerializer<T>

Gets a BinarySerializer for the reified type T.

Gets a BinarySerializer for the given type.

Link copied to clipboard
inline fun <T : Any> read(reader: ByteReader): T?

Reads a value of the reified type T? from the reader. Can return null if null was written.

inline fun <T : Any> read(bytes: ByteArray, strict: Boolean = true): T?

Reads a value of the reified type T? from bytes. Can return null if null was written.

fun <T : Any> read(type: KType, reader: ByteReader): T?

Reads a value of the type T? (type) from the reader. Can return null if null was written.

fun <T : Any> read(type: KType, bytes: ByteArray, strict: Boolean = true): T?

Reads a value of the type T? (type) from bytes. Can return null if null was written.

Link copied to clipboard
inline fun <T : Any> registerSerializer(serializer: BinarySerializer<T>)

Registers a BinarySerializer that serializes, deserializes, and copies the exact type T?.

Link copied to clipboard

Registers a BinarySerializerFactory that will be queried for serializers.

Link copied to clipboard

Sets the CbfSecurityManager that decides whether a serializer for a given type can be created.

Link copied to clipboard
inline fun <T : Any> write(value: T?): ByteArray

Writes value of the reified type T? to a ByteArray.

inline fun <T : Any> write(value: T?, writer: ByteWriter)

Writes value of the reified type T? to the writer.

fun <T : Any> write(type: KType, value: T?): ByteArray

Writes value of the type T? (type) to a ByteArray.

fun <T : Any> write(type: KType, value: T?, writer: ByteWriter)

Writes value of the type T? (type) to the writer.