Module format

Source
Expand description

Format values for controlling output formatting in AIMX expressions.

This module provides the Format struct and related functionality for representing formatting instructions in the AIMX expression language. Format values are used to control how values are displayed or serialized, providing template-like functionality for custom output generation.

§Format Structure

A Format value consists of three components:

  • instruction: The main instruction text that describes the formatting operation
  • format: A format specification enclosed in angle brackets (<format>)
  • array: A list of example values that demonstrate the format

The format follows the pattern: "Instruction" <format> "Example1", "Example2", ...

§Usage

Format values are typically used in workflow rules to define how inference results should be formatted or to provide templates for output generation. They can be evaluated and written using the standard expression evaluation infrastructure, supporting escaping and quoting modes for different contexts.

§Examples

Creating format values in Rust code:

use aimx::values::Format;
use aimx::Value;
 
let format_value = Format::new(
    "Display as currency".to_string(),
    "$0.00".to_string(),
    vec!["$42.00".to_string(), "$123.45".to_string()]
);
 
// Check that we have a format value
assert!(format_value.is_format());

See also: crate::typedef::Typedef::Format, parse_format, crate::writer::Writer::print_format

Structs§

Format
Represents a formatting instruction value in the AIMX expression language.

Functions§

parse_format
Parses a format value from input text.
parse_string_array
Parses a comma-separated list of string values.