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 largest integer reading a number builds, counted in digits. Reading
//! measures a number from its spelling before it builds anything as large
//! as its value, so what it builds is bounded by the limits, never by the
//! value; the tests of decoding hold it to that by this count. Only a test
//! build counts: elsewhere [`built`] is empty.

#[cfg(test)]
use std::cell::Cell;

#[cfg(test)]
thread_local! {
    static LARGEST: Cell<usize> = const { Cell::new(0) };
}

/// Notes that reading built an integer of `digits` digits.
#[cfg(test)]
pub(crate) fn built(digits: usize) {
    LARGEST.with(|largest| largest.set(largest.get().max(digits)));
}

/// Notes that reading built an integer of `digits` digits.
#[cfg(not(test))]
#[inline(always)]
pub(crate) fn built(_digits: usize) {}

/// What `read` returns, with the digits of the largest integer it built:
/// 0 when it built none.
#[cfg(test)]
pub(crate) fn largest_built<T>(read: impl FnOnce() -> T) -> (T, usize) {
    LARGEST.with(|largest| largest.set(0));
    let read = read();
    (read, LARGEST.with(Cell::get))
}