The jobs' little-endian binary encoding: u8, u32, u64, length-prefixed bytes and UTF-8 strings, item ranges; a reader with exact error text
$ sexc add @ajax/mesh-jobs-wire- total 3
- drwxr-xr-x-../
- drwxr-xr-x-Oct 27 05:23v/# 1 version
- drwxr-xr-x-Oct 27 05:23files/# the files of 0.1.0
- latest
- 0.1.0, published Oct 27 05:23 by ajax
- owners
- ajax
- license
- MIT
- dependencies
- @ajax/mesh-check ^0.1.0, @ajax/mesh-strbuf ^0.1.0, @ajax/mesh-jobs-ranges ^0.1.0
- dependents
- @ajax/mesh-jobs-frame, @ajax/mesh-jobs-log, @ajax/mesh-jobs-op
- keywords
- mesh alphaos jobs wire encoding
- homepage
- https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-jobs-wire
- repository
- https://github.com/thomasdavis/alpha-c-mesh
1# @ajax/mesh-jobs-wire 2 3The binary encoding the job table's ops, the job frames (F_JOB_*, F_LEASE, F_RESULT) and the job log 4are written in: little-endian `u8`, `u32`, `u64`; bytes as a `u32` length and the bytes; strings as 5their UTF-8 bytes the same way; item ranges as a `u32` count and `(start, end)` pairs. The reader 6keeps its first failure with jobs.rs's exact message (`job frame: short (3 of 8 bytes at 17)`, 7`job frame: not UTF-8`), and every read after it fails. 8 9## Ported from 10 11[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT): 12`crates/mesh-host/src/jobs.rs`, the `W` writer and the `R` reader. 13 14## Differences 15 16A string read from the wire becomes a NUL-terminated C string, so one holding a NUL byte (valid UTF-8, 17legal in a Rust `String`) is cut at it. Nothing in the mesh writes such a name. 18 19## Tests 20 21`tests/wire.c`: the exact bytes, reads back, the short-read message and its stickiness, and the UTF-8 22checks (overlong, surrogate, truncated, past U+10FFFF). 23 24## Licence 25 26MIT. See the repository's LICENSE.