Skip to main content

Module format

Module format 

Source
Expand description

Printf-style formatting node.

Takes a format string and N inputs, produces a formatted String. Uses {} placeholders (Rust-style, not C printf-style), with optional format specifiers.

Supported specifiers:

  • {} — default display
  • {:05} — zero-padded to width 5 (u64)
  • {:.2} — 2 decimal places (f64)
  • {:x} — lowercase hex (u64)
  • {:X} — uppercase hex (u64)
  • {:b} — binary (u64)
  • {:o} — octal (u64)

printf takes a Const<&str> format string, a #[poly_const] cached ParsedFormat, and &[Value] variadic wires. The cached ParsedFormat is computed once at construction (in the parse_format setup-fn) so per-eval work is just iterating the pre-parsed segments.

Structs§

FormatSpec
One placeholder’s formatting: which argument, and how to render it.
ParsedFormat
Pre-parsed format string cached on the Printf node. The #[polydat_node] macro invokes parse_format once at construction; eval reads the segments directly with no per-call parsing.
Printf
Printf-style N→1 formatting node. Variadic: accepts 0..N wire inputs.

Enums§

FmtArg
One argument to a format, as the formatter needs it: a scalar by value, a string by reference, anything else as the Value whose display form is used. The P1 node builds these from its Value inputs and the compiled helper from slot bits and handles, so both tiers run the same formatting code (SRD 115 §6, axiom H7) and a string argument is formatted without being copied first.
Segment
A parsed format segment: either literal text or a placeholder.