~/bend-docscommunity

src/coordinator/CursorCodec.bend checks

raw source on the hub · import mylsm-lsm-store@0.6.0.2/src/coordinator/CursorCodec.bend as CursorCodec

2 imports
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

Types

type Frame source · line 5 · raw

Type

Represents one incremental cursor response frame.

type Decision source · line 10 · raw

Type

Reports a decoded cursor frame or malformed wire bytes.

Definitions

def u32.bytes source · line 15 · raw

@value:U32 -> 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes

Encodes one exact byte offset and length into a fixed-width word.

def nat.duplicate.step source · line 18 · raw

@pair:Pair(Nat, Nat) -> Pair(Nat, Nat)

def nat.duplicate source · line 22 · raw

@value:Nat -> Pair(Nat, Nat)

def u32.duplicate.result source · line 27 · raw

@pair:Pair(Nat, Nat) -> Pair(U32, U32)

def u32.duplicate source · line 31 · raw

@value:U32 -> Pair(U32, U32)

def slice.result source · line 35 · raw

@pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes

Extracts the owned byte sequence from the bytes package slice result.

def end.tag source · line 40 · raw

0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes

Returns the one-byte tag for terminal cursor state.

def item.tag source · line 44 · raw

0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes

Returns the one-byte tag for an item carrying raw key and value bytes.

def item.measured source · line 48 · raw

@key_size:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, U32) -> @value_size:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, U32) -> 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes

Encodes retained key/value buffers after measuring each exact byte length.

def item source · line 60 · raw

@key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @value:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes

Encodes a cursor item using explicit lengths and no text conversion.

def encode source · line 67 · raw

@frame:Frame -> 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes

Encodes End separately from an item whose key and value are empty.

def tag.matches source · line 73 · raw

@pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Bool)) -> Bool

Extracts exact byte equality from the bytes package comparison result.

def end.checked source · line 78 · raw

@is_end:Bool -> @exact:Bool -> Decision

Decodes the terminal marker only when no trailing bytes remain.

def item.value.paired source · line 90 · raw

@pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @key:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Decision

Combines the exact key and value byte slices into one cursor item.

def item.value.key.sliced source · line 98 · raw

@pair:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @value_offset:U32 -> @value_length:U32 -> Decision

Creates the value slice from the source retained by the key slice.

def item.value.slices source · line 108 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @key_lengths:Pair(U32, U32) -> @value_length:U32 -> Decision

Slices the key first so the source remains available for the value slice.

def item.value.bound.checked source · line 119 · raw

@exact:Bool -> @payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @key_length:U32 -> @value_length:U32 -> Decision

Accepts only an exact frame length after reading the value length.

def item.value.bound.compare source · line 131 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @key_lengths:Pair(U32, U32) -> @value_lengths:Pair(U32, U32) -> Decision

Accepts only a value length that ends exactly at the frame boundary.

def item.value.bound source · line 147 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @key_length:U32 -> @value_length:U32 -> Decision

Duplicates lengths for exact validation and the returned value slice.

def item.value.parsed source · line 157 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @key_length:U32 -> @parsed:Maybe<&2, U32> -> Decision

Distinguishes a complete value length from a truncated header.

def item.value.length source · line 169 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @key_length:U32 -> @parsed:Maybe<&2, U32> -> Decision

Reads the value length at the boundary immediately after the key.

def item.key.bound.read source · line 178 · raw

@read:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Maybe<&2, U32>) -> @size:U32 -> @key_length:U32 -> Decision

Checks that the key length leaves room for the value length word.

def item.key.bound.read.offset source · line 188 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @key_lengths:Pair(U32, U32) -> Decision

Checks that the key length leaves room for the value length word.

def item.key.bound.checked source · line 200 · raw

@has_value_header:Bool -> @payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @key_length:U32 -> Decision

Checks that the key length leaves room for the value length word.

def item.key.bound.check source · line 213 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @sizes:Pair(U32, U32) -> @key_lengths:Pair(U32, U32) -> Decision

Accepts key lengths that leave a complete value length word.

def item.key.bound.compare source · line 228 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @key_lengths:Pair(U32, U32) -> Decision

Accepts key lengths that leave a complete value length word.

def item.key.bound source · line 236 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @key_length:U32 -> Decision

Accepts key lengths that leave a complete value length word.

def item.key.parsed source · line 244 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @parsed:Maybe<&2, U32> -> Decision

Accepts the key-length field only when all required bytes are present.

def item.key.length source · line 254 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @parsed:Maybe<&2, U32> -> Decision

Reads the key length before deriving the value-length offset.

def item.header.read source · line 262 · raw

@read:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Maybe<&2, U32>) -> @size:U32 -> Decision

Routes complete item headers to the key-length decoder.

def item.header.checked source · line 270 · raw

@has_header:Bool -> @payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> Decision

Routes complete item headers to the key-length decoder.

def item.header.compare source · line 281 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @sizes:Pair(U32, U32) -> @is_item:Bool -> Decision

Checks header capacity while retaining its total for later framing checks.

def item.header.size source · line 292 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @is_item:Bool -> Decision

Rejects item headers that cannot contain both length words.

def decode.item source · line 300 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @is_item:Bool -> Decision

Routes the item tag to exact length-prefixed decoding.

def decode.item.tag.sliced source · line 308 · raw

@sliced:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @size:U32 -> Decision

Decodes the item marker from the retained response source.

def decode.item.tag source · line 318 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> Decision

Retains the response source while comparing the item marker.

def decode.tag.end.checked source · line 325 · raw

@is_end:Bool -> @payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @sizes:Pair(U32, U32) -> Decision

Selects End validation or item decoding after the terminal tag check.

def decode.tag.end source · line 340 · raw

@sliced:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @size:U32 -> Decision

Checks the terminal marker while retaining bytes for item-tag decoding.

def decode.nonempty source · line 350 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @size:U32 -> @is_nonempty:Bool -> Decision

Validates that a nonempty encoded response has a supported tag.

def decode.size.checked source · line 360 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @sizes:Pair(U32, U32) -> Decision

Decodes a complete cursor response, rejecting unknown tags and trailing data.

def decode.measured source · line 369 · raw

@measured:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, U32) -> Decision

Decodes a complete cursor response, rejecting unknown tags and trailing data.

def decode source · line 374 · raw

@payload:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Decision

Decodes a complete cursor response from its exact byte payload.