Ivan FB 05595e2d92
feat(ffi): target nim-ffi master (v0.2.0) — CBOR + event registry
Port the {.ffi.} wrapper to nim-ffi 0.2.0 (master). 0.2.0 is a breaking
redesign over 0.1.4: events move to a per-context multi-listener registry
(sds_add_event_listener / sds_remove_event_listener) fired via {.ffiEvent.}
emitters, and request/response/event marshalling switches from JSON to CBOR.

- libsds.nim: typed {.ffiEvent.} payloads replace the JSON event modules;
  CBOR handles nesting, so unwrap returns a typed response again. The
  retrieval-hint provider (a C function pointer, not CBOR-encodable) passes
  its address as a uint64 via a {.ffi.} method that stores it in a
  worker-thread threadvar.
- pin nim-ffi to master HEAD by commit. The lock version is kept a clean
  semver ("0.2.0") on purpose: nimble's `#`-prefixed special version in the
  lock breaks `nimble setup -l` (an unquoted `#` truncates the git path),
  so only vcsRevision carries the commit.
- add the new transitive dep cbor_serialization to the lock and nix/deps.nix.
- regenerate libsds.h for the CBOR/registry ABI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 13:22:11 +02:00
2026-04-10 14:23:30 +02:00
2026-04-10 14:23:30 +02:00
2026-02-03 19:05:46 +00:00

nim-sds

Nim implementation of the e2e reliability protocol.

Prerequisites

  • Nix package manager

Quick start

git clone https://github.com/logos-messaging/nim-sds.git
cd nim-sds

# Build the shared library
nix build '.#libsds'

# Run tests
nix develop --command nimble test

Building

Desktop

nix build --print-out-paths '.#libsds'

Android

nix build --print-out-paths '.#libsds-android-arm64'
nix build --print-out-paths '.#libsds-android-amd64'
nix build --print-out-paths '.#libsds-android-x86'
nix build --print-out-paths '.#libsds-android-arm'

iOS

nix build --print-out-paths '.#libsds-ios'
Development shell

Enter the dev shell:

nix develop

Build using nimble tasks:

# Dynamic library (auto-detects OS)
nimble libsdsDynamicMac    # macOS
nimble libsdsDynamicLinux  # Linux
nimble libsdsDynamicWindows # Windows

# Static library
nimble libsdsStaticMac     # macOS
nimble libsdsStaticLinux   # Linux
nimble libsdsStaticWindows # Windows

Run tests:

nimble test

The built library is output to build/.

Android (without Nix)

Download the latest Android NDK:

cd ~
wget https://dl.google.com/android/repository/android-ndk-r27c-linux.zip
unzip android-ndk-r27c-linux.zip

Add to ~/.bashrc:

export ANDROID_NDK_ROOT=$HOME/android-ndk-r27c
export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH

Then build:

ARCH=arm64 nimble libsdsAndroid
Architecture Command
arm64 ARCH=arm64 nimble libsdsAndroid
amd64 ARCH=amd64 nimble libsdsAndroid
x86 ARCH=x86 nimble libsdsAndroid

The library is output to build/libsds.so.

Dependency management

Dependencies are managed by Nimble and pinned via nimble.lock.

To set up dependencies locally:

nimble setup -l

To update dependencies:

nimble lock

After updating nimble.lock, the Nix outputHash in nix/deps.nix must be recalculated by running nix build and updating the hash from the error output.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Description
Nim implementation of the e2e reliability protocol
Readme
Languages
Nim 91.9%
Nix 5.9%
Shell 1.5%
C 0.7%