Rust's text rules in C: Debug-quoted strings, durations, shortest floats, number parsing, lossy UTF-8
$ sexc add @ajax/mesh-rsfmt- 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-buf ^0.1.0, @ajax/mesh-check ^0.1.0
- dependents
- @ajax/mesh-args, @ajax/mesh-control, @ajax/mesh-driver, @ajax/mesh-http-relay, @ajax/mesh-infer-request, @ajax/mesh-infer-svc, @ajax/mesh-infer-wire, @ajax/mesh-inferd, @ajax/mesh-load-proc, @ajax/mesh-load-text, @ajax/mesh-shared, @ajax/meshd
- keywords
- mesh alphaos format rust
- homepage
- https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-rsfmt
- repository
- https://github.com/thomasdavis/alpha-c-mesh
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.