osmaczko 0a6e833b53
feat: implement Client crate and C FFI bindings
Implement a `client` crate that wraps the `libchat` context behind a
simple `ChatClient<D>` API. The delivery strategy is pluggable via a
`DeliveryService` trait, with two implementations provided:

- `InProcessDelivery` — shared `MessageBus` for single-process tests
- `CDelivery` — C function-pointer callback for the FFI layer

Add a `client-ffi` crate that exposes the client as a C API via
`safer-ffi`. A `generate-headers` binary produces the companion C
header.

Include two runnable examples:
- `examples/in-process` — Alice/Bob exchange using in-process delivery
- `examples/c-ffi` — same exchange written entirely in C; smoketested
under valgrind (to catch memory leaks) in CI

iterates: #71
2026-03-30 21:24:29 +02:00

77 lines
2.0 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
- run: cargo build --verbose
- run: cargo test --verbose
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
- run: rustup component add clippy
- run: cargo clippy --all-targets --all-features -- -D warnings
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
- run: rustup component add rustfmt
- run: cargo fmt --all -- --check
nim-bindings-test:
name: Nim Bindings Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
- name: Install Nim via choosenim
run: |
curl https://nim-lang.org/choosenim/init.sh -sSf | sh -s -- -y
echo "$HOME/.nimble/bin" >> $GITHUB_PATH
- run: nimble install -dy
working-directory: nim-bindings
- run: nimble test
working-directory: nim-bindings
- run: nimble pingpong
working-directory: nim-bindings
c-ffi-smoketest:
name: C FFI Smoketest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
- name: Install valgrind
run: sudo apt-get install -y valgrind
- name: Build C FFI example
run: make
working-directory: examples/c-ffi
- name: Run C FFI smoketest
run: ./c-client
working-directory: examples/c-ffi
- name: Run C FFI smoketest under valgrind
run: make valgrind
working-directory: examples/c-ffi