flow-abi 0.1.0

The value encoding at the host boundary: type-directed JSON encoding and decoding, the canonical form and its hash, JSON Schemas, and Tool declaration fingerprints.
Documentation
//! The value encoding at the host boundary (`docs/runtime/spec/abi.md`).
//!
//! Every Flow data value that leaves a run's address space, and every value
//! history stores, is JSON under one set of rules, and both sides know the
//! declared type, so the encoding carries no type tags of its own. This crate
//! is those rules:
//!
//! - [`encode`] writes a value at its type, and [`canonical`] gives the one
//!   text every equal value shares, over which every hash is taken
//!   ([`Digest`]);
//! - [`decode`] and [`decode_text`] build a value of a declared type from
//!   JSON by the decoding table, refusing with where and why
//!   ([`DecodeError`]), in reply or run-input [`Mode`] and within [`Limits`],
//!   and rebuild a value the program made from its canonical text;
//! - [`encode_checkpoint`] and [`rebuild`] write and read a checkpoint's
//!   arguments, the one place a task has an encoding: the id of the call it
//!   is parked on;
//! - [`schema`] writes a type's JSON Schema;
//! - [`TypeSpec`] validates finite declaration templates and concrete generic
//!   calls, with [`Terms`] and [`call_types`] sharing their one term writer;
//! - [`Signature::fingerprint`] hashes a `@tool` declaration's canonical
//!   signature.
//!
//! # The types it reads
//!
//! The encoding is a function of declarations, not of checking, so this
//! crate does not depend on the checker. It reads a [`Type`] — the checker's
//! types cut down to what crosses — whose declared records, enums and host
//! types live in a [`Catalog`] that holds the same `flow-value` shapes the
//! evaluator builds values with. Whoever holds a checked program builds the
//! catalog from it once; a history reader or a host needs only the catalog.
//!
//! # JSON
//!
//! The reader and writer are this crate's own ([`Json`], [`parse`]): numbers
//! are exact at any size, an object naming a key twice and a lone surrogate
//! escape are refused, nesting is bounded, and the writer is the canonical
//! form. No dynamic tree from a general-purpose library stands beside the
//! type-directed one.
//!
//! # Not here
//!
//! The Tool process protocol's messages, binding, `flow.toml`, toolkits
//! and adapters are the host's, built on this crate.

mod decode;
mod encode;
mod error;
mod fingerprint;
mod json;
mod judge;
mod limits;
mod metadata;
mod schema;
mod time;
mod types;

pub use decode::{Mode, decodable, decode, decode_text, rebuild};
pub use encode::{Digest, canonical, canonical_within, encode, encode_checkpoint};
pub use error::{DecodeError, DecodeErrorKind, EncodeError};
pub use fingerprint::{Signature, ToolDecl};
pub use json::{Json, parse};
pub use judge::crossable;
pub use limits::Limits;
pub use metadata::{Terms, TypeSpec, ValidatedTypes, call_types};
pub use schema::{DIALECT, schema};
pub use types::{Body, Catalog, Decl, DeclId, Identity, MemberDoc, Origin, Type};

/// The data version: one version for the value encoding, the Tool protocol
/// and the history format together, written `"major.minor"` (`abi.md`,
/// `trace.md`, *The data version*). No data version is stable before the
/// first public release.
pub const DATA_VERSION: &str = "0.1";