1# @ajax/mesh-rsfmt
23The text Rust's formatting machinery produces, so the C meshd answers byte for byte as the Rust one:
45| 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` |
1112## Ported from
1314[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).
1718## Tests
1920- `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).
2223## Differences
2425- `{:?}` 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.
2829## Licence
3031MIT. See the repository's LICENSE.