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).
- 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)
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.
- Java 21 or later
- sbt 1.10+
sbt:
libraryDependencies += "io.twilic" %% "twilic" % "3.0.0"Maven:
<dependency>
<groupId>io.twilic</groupId>
<artifactId>twilic_3</artifactId>
<version>3.0.0</version>
</dependency>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))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)Run checks locally:
sbt scalafmtCheck testRust client interop smoke check (Scala server -> Rust client):
bash scripts/check-rust-client-interop.shScala client interop smoke check (Rust server -> Scala client):
bash scripts/check-scala-client-interop.shRun both directions:
bash scripts/check-interop.shNote: these scripts expect ../twilic-rust to exist as a sibling directory.
Documentation is formatted and linted with Prettier and markdownlint (see docs/CONTRIBUTING.md).
- CI workflow:
.github/workflows/ci.yml - Interop workflow:
.github/workflows/interop.yml - Release workflow:
.github/workflows/publish-maven.yml(tagv*must matchVersion.VERSION)
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.
This project is licensed under the MIT License - see the LICENSE file for details.