flow-abi 0.1.0-rc.5

The host boundary's value encoding: the binary encoding and the JSON form, the canonical form and its hash, JSON Schemas, Tool signatures, and the answers a Tool call passes.
Documentation
//! The Python toolkit's description numbers, rendered from these
//! declarations.

use std::fmt::Write as _;

use super::*;
use crate::version::DATA_VERSION;
use crate::wire::Declared;

/// The Python toolkit's module of the description's constructor numbers and
/// the data version, rendered from the declarations.
fn python() -> String {
    let mut out = String::from(
        "\"\"\"The constructor numbers of the type descriptions' enums (abi.md, *Type\n\
         descriptions*) and the data version, rendered from flow-abi's declarations of\n\
         them by its tests. FLOW_BLESS=1 cargo test -p flow-abi rewrites this file;\n\
         do not edit it by hand.\n\"\"\"\n\n",
    );
    writeln!(out, "DATA_MAJOR = {}", DATA_VERSION.major).expect("a string");
    writeln!(out, "DATA_MINOR = {}", DATA_VERSION.minor).expect("a string");
    for shape in [
        Term::shape(),
        Owner::shape(),
        Body::shape(),
        Payload::shape(),
    ] {
        out.push('\n');
        for (name, number) in shape.constants() {
            writeln!(out, "{name} = {number}").expect("a string");
        }
    }
    out
}

#[test]
fn the_python_toolkit_s_numbers_are_these_declarations() {
    let module = flow_testing::repository_root()
        .join("toolkits/python/src/flow_toolkit/_wire_descriptions.py");
    if let Err(error) = flow_testing::compare_snapshot(&module, &python()) {
        panic!("{error}");
    }
}