org.sigilaris.core.application.support.encoding

Members list

Type members

Classlikes

trait PathEncoder[Path <: Tuple]

Typeclass for encoding paths at runtime.

Typeclass for encoding paths at runtime.

This allows encoding paths when the path type is known at compile time but we need to compute the bytes at runtime (e.g., in typeclass derivation).

Type parameters

Path

the path tuple type

Attributes

Companion
object
Source
PathEncoding.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object empty
object PathEncoder

Companion for PathEncoder, providing derivation instances for empty and non-empty paths.

Companion for PathEncoder, providing derivation instances for empty and non-empty paths.

Attributes

Companion
trait
Source
PathEncoding.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait SegmentCollector[T <: Tuple]

Helper typeclass to collect path segments as a list of strings for runtime encoding.

Helper typeclass to collect path segments as a list of strings for runtime encoding.

Type parameters

T

the path tuple type

Attributes

Companion
object
Source
PathEncoding.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Companion for SegmentCollector, providing derivation instances.

Companion for SegmentCollector, providing derivation instances.

Attributes

Companion
trait
Source
PathEncoding.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Shared deterministic codecs for pair-shaped table keys.

Shared deterministic codecs for pair-shaped table keys.

Attributes

Source
TupleKeyCodecs.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

inline def encodePath[Path <: Tuple]: ByteVector

Encode a path (tuple of string segments) into a byte vector.

Encode a path (tuple of string segments) into a byte vector.

Format: length(num_segments) ++ segment1 ++ segment2 ++ ...

The path-level length header ensures that shorter paths cannot be prefixes of longer paths, even when segments are empty. This is critical for the prefix-free guarantee across all table prefixes.

Type parameters

Path

the path tuple type

Attributes

Returns

the encoded path

Source
PathEncoding.scala
def encodePathRuntime(path: List[String]): ByteVector

Runtime encoding for a path given as a List[String].

Runtime encoding for a path given as a List[String].

Format: length(num_segments) ++ segment1 ++ segment2 ++ ...

The path-level length header ensures prefix-freedom across paths of different lengths.

Value parameters

path

the path segments as a list

Attributes

Returns

the encoded path bytes

Source
PathEncoding.scala
inline def encodeSegment[S <: String]: ByteVector

Encode a string segment with length-prefix and null terminator.

Encode a string segment with length-prefix and null terminator.

Format: length(segment_bytes) ++ segment_bytes ++ 0x00

The length-prefix ensures we can read back the exact segment, and the null terminator provides a clear boundary for debugging and visual inspection.

This encoding is prefix-free: no encoded segment can be a prefix of another.

Type parameters

S

the string literal type

Attributes

Returns

the encoded byte vector

Source
PathEncoding.scala
def encodeSegmentRuntime(s: String): ByteVector

Runtime encoder for string segments.

Runtime encoder for string segments.

Encodes a string at runtime using the same format as encodeSegment.

Value parameters

s

the string to encode

Attributes

Returns

the encoded byte vector

Source
PathEncoding.scala
inline def lenBytes(n: Int): ByteVector

Length-prefix encoding for a non-negative integer.

Length-prefix encoding for a non-negative integer.

Encodes the length as a BigNat using the standard BigNat byte encoder.

Value parameters

n

the length to encode (must be non-negative)

Attributes

Returns

the byte representation

Source
PathEncoding.scala
def lenBytesRuntime(n: Int): ByteVector

Runtime version of lenBytes.

Runtime version of lenBytes.

Encodes the length as a BigNat using the standard BigNat byte encoder.

Value parameters

n

the length to encode (must be non-negative)

Attributes

Returns

the byte representation

Source
PathEncoding.scala
inline def tablePrefix[Path <: Tuple, Name <: String]: ByteVector

Compute the full table prefix for a table at the given path.

Compute the full table prefix for a table at the given path.

The prefix is: encodePath(Path) ++ encodeSegment(Name)

This is the byte prefix that will be prepended to all keys stored in this table.

Type parameters

Name

the table name

Path

the mount path tuple

Attributes

Returns

the full table prefix

Source
PathEncoding.scala
def tablePrefixRuntime[Path <: Tuple](tableName: String)(using pathEncoder: PathEncoder[Path]): ByteVector

Compute the table prefix at runtime using PathEncoder.

Compute the table prefix at runtime using PathEncoder.

This is a runtime version of tablePrefix that works with abstract type parameters.

Type parameters

Path

the mount path tuple

Value parameters

pathEncoder

the path encoder (automatically derived)

tableName

the table name

Attributes

Returns

the full table prefix

Source
PathEncoding.scala
def tablePrefixRuntimeFromList(path: List[String], tableName: String): ByteVector

Runtime computation of table prefix from a dynamic path list.

Runtime computation of table prefix from a dynamic path list.

This is useful for property testing where both paths and table names are generated dynamically.

Value parameters

path

the path segments as a list

tableName

the table name

Attributes

Returns

the full table prefix

Source
PathEncoding.scala