DynamicDomainCodec

internal class DynamicDomainCodec<T : Any>(val oid: Int, val pgTypeName: String, val pgSchema: String, baseTypeOid: Int, typeRegistry: TypeRegistry) : TypeCodec<T>

Codec for PostgreSQL domain types, which are essentially custom types based on underlying base types. It delegates serialization and deserialization to the codec of the base type.

Type Parameters

T

The Kotlin type of the underlying base type.

Constructors

Link copied to clipboard
constructor(oid: Int, pgTypeName: String, pgSchema: String, baseTypeOid: Int, typeRegistry: TypeRegistry)

Properties

Link copied to clipboard
open override val fromBinary: (ByteArray, Int, Int) -> T

Function to deserialize a value from a PostgreSQL binary format.

Link copied to clipboard
open override val isDefaultForKotlinType: Boolean = false

Whether this codec is the default for its Kotlin type.

Link copied to clipboard
open override val kotlinClass: KClass<T>

The Kotlin class this codec handles.

Link copied to clipboard
open override val oid: Int

The OID of the domain type.

Link copied to clipboard
open override val pgSchema: String

The schema where the domain type is defined.

Link copied to clipboard
open override val pgTypeName: String

The name of the domain type in PostgreSQL.

Link copied to clipboard
open override val toBinary: (T, PgByteWriter) -> Unit

Function to serialize a value to a PostgreSQL binary format.

Functions

Link copied to clipboard
internal fun <T : Any> TypeCodec<T>.decodeSafely(data: ByteArray, offset: Int, length: Int): T

Safely decodes a value using this TypeCodec. Any standard exceptions (like IllegalArgumentException or IllegalStateException) thrown by the codec's TypeCodec.fromBinary method are caught and wrapped in a CodecException.

Link copied to clipboard
internal fun <T : Any> TypeCodec<T>.encodeSafely(value: T, writer: PgByteWriter)

Safely encodes a value using this TypeCodec. Any standard exceptions (like IllegalArgumentException or IllegalStateException) thrown by the codec's TypeCodec.toBinary method are caught and wrapped in a CodecException.