LeanLmdb. ValueCodec behaviour
(lean_lmdb v0.3.0)
View Source
Behaviour for opt-in value serialization used by LeanLmdb.CodecDatabase.
Codec callbacks run in the caller process before or after a native call. The native LMDB layer continues to receive and return binaries only.
id/0 and version/0 describe the persisted format. IDs must be stable
non-empty binaries no larger than 255 bytes. A decoder receives the version
stored with each value so it can support explicit format migrations.
Stored bytes are untrusted input. Decoders must reject malformed versions, bound encoded input, and—especially for compression—enforce a finite decoded output limit before allocating expanded data. Callback errors and exceptions are normalized to stable LeanLmdb errors. LeanLmdb never selects a callback module from stored bytes.
Summary
Types
@type options() :: keyword()
Runtime options retained by a codec database handle.
Callbacks
@callback decode(payload :: binary(), stored_version :: non_neg_integer(), options()) :: {:ok, term()} | {:error, term()}
@callback deterministic?() :: boolean()
@callback id() :: binary()
@callback version() :: non_neg_integer()