skip to content
[readonly]
==> README.md <==
1# @ajax/mesh-rsfmt
2
3The text Rust's formatting machinery produces, so the C meshd answers byte for byte as the Rust one:
4
5| Rust | C |
6|---|---|
7| `{:?}` of a `str` (`"no program \"x\""`) | `mesh_rs_debug_str`, `mesh_rs_debug_cstr` |
8| `{:?}` of a `Duration` (`10s`, `1.5s`, `500ms`, `40µs`) | `mesh_rs_duration`, `mesh_rs_duration_ms` |
9| `{}` of an `f32` / `f64` (shortest round-trip digits, no exponent) | `mesh_rs_f32`, `mesh_rs_f64` |
10| `{:.p}` of a float | `mesh_rs_fixed` |
11
12## Ported from
13
14[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT): the formats used in
15`crates/mesh-host`'s replies and logs (core::fmt's `escape_debug`, core::time's `fmt_decimal`, the
16float `Display` impl).
17
18## Tests
19
20- `tests/rsfmt.c`: every expected string is what rustc 1.88's `format!` prints for the same value
21  (generated with a throwaway Rust program).
22
23## Differences
24
25- `{:?}` of a string escapes ASCII control characters exactly as Rust does; Rust also escapes some
26  non-printable non-ASCII code points (C1 controls, unassigned and grapheme-extend characters), which
27  this passes through unchanged. meshd's replies only quote names, paths and protocol words.
28
29## Licence
30
31MIT. See the repository's LICENSE.