8000
Skip to content

Repository files navigation

Twilic (Scala)

Scala 3 implementation of the Twilic wire format and session-aware encoder/decoder.

This library's default encode / decode API targets Twilic v2 (v3 support pending).

What this library provides

  • Dynamic encoding/decoding (encode, decode)
  • Schema-aware encoding (encodeWithSchema)
  • Batch and micro-batch encoding (encodeBatch, SessionEncoder.encodeMicroBatch)
  • Stateful features (base snapshots, state patch, template batch, control stream, trained dictionary)

Project layout

twilic-scala/
  src/main/scala/io/twilic/           # public Scala API
  src/main/java/io/twilic/internal/  # protocol core (Java, shared with reference SDK)
  src/test/scala/                      # spec conformance and interop tests (ScalaTest)
  scripts/                             # Rust interop fixtures and smoke checks
  docs/

The public package is io.twilic. Implementation details live under io.twilic.internal.core.

Requirements

  • Java 21 or later
  • sbt 1.10+

Install

sbt:

libraryDependencies += "io.twilic" %% "twilic" % "3.0.0"

Maven:

<dependency>
  <groupId>io.twilic</groupId>
  <artifactId>twilic_3</artifactId>
  <version>3.0.0</version>
</dependency>

Quick start

import io.twilic.Twilic
import io.twilic.internal.core.*

val value = Twilic.newMap(
  Twilic.entry("id", Twilic.newU64(1001)),
  Twilic.entry("name", Twilic.newString("alice")),
)

val bytes = Twilic.encode(value)
val decoded = Twilic.decode(bytes)

println(Twilic.equal(decoded, value))

Session encoder example

import io.twilic.Twilic
import io.twilic.internal.core.*

val enc = Twilic.newSessionEncoder()
val value = Twilic.newMap(
  Twilic.entry("id", Twilic.newU64(1)),
  Twilic.entry("role", Twilic.newString("admin")),
)
enc.encode(value)

Development

Run checks locally:

sbt scalafmtCheck test

Rust client interop smoke check (Scala server -> Rust client):

bash scripts/check-rust-client-interop.sh

Scala client interop smoke check (Rust server -> Scala client):

bash scripts/check-scala-client-interop.sh

Run both directions:

bash scripts/check-interop.sh

Note: these scripts expect ../twilic-rust to exist as a sibling directory.

Markdown formatting

Documentation is formatted and linted with Prettier and markdownlint (see docs/CONTRIBUTING.md).

CI and release (GitHub Actions)

  • CI workflow: .github/workflows/ci.yml
  • Interop workflow: .github/workflows/interop.yml
  • Release workflow: .github/workflows/publish-maven.yml (tag v* must match Version.VERSION)

Spec parity

This library mirrors the Twilic wire format spec at twilic/twilic and stays in lockstep with the Rust, Java, and Python reference implementations.

See docs/SPEC-TEST-TRACEABILITY.md for the spec-section to test mapping.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Scala implementation of a fast, compact binary wire format for modern data transport.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0