tink-crystal

tink data-flow node frame protocol - Crystal module

tink-crystal

tink data-flow node frame protocol — Crystal module (no dependencies). Universal and language-agnostic: any component that obeys the frame protocol can join a tink pipeline.

帧 = [ len: u32 BE ][ payload: len 字节 ][ crc: u32 BE ]
len = payload 字节数
crc = CRC32-IEEE(payload)(多项式 0xEDB88320)

Mirrors ext/tink.tie (tie standard library) and the other-language tink libraries; pure functions over Bytes, IO (stdin/stdout) left to the caller. Names follow the Crystal convention (Tink module, snake_case methods).

API (module Tink)

function description
Tink.crc32(data) -> UInt32 CRC32-IEEE over a Bytes. Check vector: Tink.crc32("123456789") == 0xCBF43926
Tink.frame_encode(payload) -> Bytes encode a payload into a full frame [len][payload][crc]
Tink.frame_next(bytes, pos) -> Frame? parse one frame at pos, verify CRC; Frame(payload, next) on success, nil on out-of-bounds / mismatch
Tink.frame_skip(bytes, pos) -> Int32? skip one frame at pos without copying or verifying; nil on out-of-bounds

Usage

require "./tink"
frame = Tink.frame_encode(Bytes[1, 2, 3])
got = Tink.frame_next(frame, 0) # Tink::Frame?

Test

crystal run test_tink.cr

Cross-language

tink 帧协议各语言实现(API 语义与校验向量一致):

language library
tie ext/tink.tie
Rust tink-rust(tink crate)
C tink-c(tink.h + tink.c)
Python tink-python(tink.py)
JavaScript tink-js(tink.js + tink.d.ts)
C++ tink-cpp(tink.hpp)
Java tink-java(org.tielang.tink)
C# tink-csharp(namespace Tink)
Go tink-go(package tink)
Zig tink-zig(tink.zig)
Lua tink-lua(tink.lua)
GDScript tink-godot(tink.gd)
F# tink-fsharp(Tink.fs)
PowerShell tink-powershell(tink.ps1)
Kotlin tink-kotlin(Tink.kt)
Ruby tink-ruby(tink.rb)
Julia tink-julia(tink.jl)
Nim tink-nim(tink.nim)
Dart tink-dart(tink.dart)
Crystal this module(tink-crystal)

License

本仓库使用 Tie Public License v2.0 (TPL 2.0),完整文本见 LICENSE。 This repository is distributed under the Tie Public License v2.0 (TPL 2.0) — see LICENSE for the full text.

Repository

tink-crystal

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 0
  • about 1 hour ago
  • August 31, 2026
License

Other

Links
Synced at

Sun, 18 Oct 2026 13:54:58 GMT

Languages