Skip to main content

Crate flow_toolkit

Crate flow_toolkit 

Source
Expand description

The Rust toolkit for Tool implementations (docs/runtime/spec/abi.md, Toolkits).

§Ordinary Rust functions

Annotate public functions with tool and derive Flow for boundary records and enums. A direct .rs import selects a module in its Cargo library; the flow-toolkit CLI prepares its generated launcher. Function bodies remain directly callable by Rust tests. An optional lifecycle initializer returns a Resource whose asynchronous or synchronous cleanup runs after calls drain at normal shutdown; an injected Context retrieves the shared resource and writes call-correlated operational logs through Context::log. Native build and metadata extraction happen during explicit preparation; metadata-only reads never compile or invoke bodies.

§Types

FlowRust
IntInt, exact at any size
DecimalDecimal, exact, never binary floating point
Bool, Text, Unit, Neverbool, String, (), Infallible
BytesBytes
Duration, InstantDuration, Instant: exact seconds
List<T>, Set<T>, Dict<K, V>Vec<T>, BTreeSet<T>, BTreeMap<K, V>
Option<T>, tuplesOption<T>, tuples
json.ValueJsonValue, with Flow’s equality and order
a record, an enuma struct, an enum
a @tool type#[derive(Flow)] #[flow(opaque)] String newtype
a Tool’s type parameterValue, admitted through ContextCodec
a parameter-dependent Set or DictContextSet, ContextDict

Generic calls carry validated schemas and type descriptions. The automatic bridge instantiates generic Rust functions with typed erased values and applies contextual codecs through their native containers, records and enum payloads. Ordinary monomorphic values keep their native Rust representation.

Narrowing an Int to a fixed width is the author’s own checked conversion.

§Answers

A call whose arguments do not decode is answered NotRun, as is one naming a declaration this implementation does not serve; a method that panics is answered Unknown (abi.md, Toolkits). A cancel sets the call’s Context::cancelled; it proves nothing, and a reply sent after it is harmless. Calls run concurrently, one thread each.

Re-exports§

pub use data::Bytes;
pub use data::ContextCodec;
pub use data::ContextDict;
pub use data::ContextSet;
pub use data::Data;
pub use data::JsonValue;
pub use data::PayloadView;
pub use data::parse_json;

Modules§

data
Values converted under the value encoding (abi.md, The value encoding and Decoding): Data for every Rust type a Flow data type maps to, and the pieces generated records and enums are written with.

Structs§

Context
What a method knows about the call it answers.
Decimal
An exact decimal number.
DecodeError
Why decoding refused. The path and problem fields are json.DecodeError’s shape (stdlib.md); kind preserves host refusal metadata. A new Tool reply that fails decoding is BadReply with this explanation (abi.md, Decoding).
Duration
A length of time, ordered by length.
Instant
A point in time, ordered chronologically.
Int
An integer, with no bound.
Resource
A process resource retained across calls and explicitly closed at normal shutdown.
ValidatedTypes
An immutable concrete call graph after complete validation.
Value
A generic Tool value admitted through a validated concrete call codec. The index distinguishes independent native type parameters at the automatic bridge.

Enums§

DecodeErrorKind
Why decoding refused, independently of its human-readable explanation.
Json
A JSON value.
Problem
Why a call did not produce its success value.

Traits§

FlowType
A native boundary value with contextual conversion for generic calls. Native scalars, containers and #[derive(Flow)] supply implementations.

Attribute Macros§

lifecycle
Registers one optional process resource initializer without an authored launcher.
tool
Exports an ordinary function through a generated typed Tool adapter.

Derive Macros§

Flow
Derives exact Flow encoding and declaration metadata for records and enums.