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 std/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 std/tink.tie
Rust tink-rust(tink crate)
C tink-ctink.h + tink.c
Python tink-pythontink.py
JavaScript tink-jstink.js + tink.d.ts
C++ tink-cpptink.hpp
Java tink-javaorg.tielang.tink
C# tink-csharp(namespace Tink
Go tink-go(package tink
Zig tink-zigtink.zig
Lua tink-luatink.lua
GDScript tink-godottink.gd
F# tink-fsharpTink.fs
PowerShell tink-powershelltink.ps1
Kotlin tink-kotlinTink.kt
Ruby tink-rubytink.rb
Julia tink-juliatink.jl
Nim tink-nimtink.nim
Dart tink-darttink.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
  • 14 minutes ago
  • August 31, 2026
License

Other

Links
Synced at

Tue, 08 Sep 2026 10:32:55 GMT

Languages