Expand description
§torvyn-types
Shared foundation types for the Torvyn reactive streaming runtime.
This crate is the universal leaf dependency — every other Torvyn crate imports from it. It contains identity types, error types, domain enums, state machines, shared records, traits, and constants.
§Design principles
- Zero internal dependencies: this crate depends only on
stdandserde. - Zero unsafe code:
#![forbid(unsafe_code)]. - Complete documentation:
#![deny(missing_docs)]. - Minimal footprint: compiles in under 2 seconds.
§Quick reference
| Category | Key types |
|---|---|
| Identity | ComponentTypeId, ComponentInstanceId, ComponentId, FlowId, StreamId, ResourceId, BufferHandle, TraceId, SpanId |
| Errors | ProcessError, TorvynError, ContractError, LinkError, ResourceError, ReactorError, ConfigError, SecurityError, PackagingError |
| Enums | ComponentRole, BackpressureSignal, BackpressurePolicy, ObservabilityLevel, Severity, CopyReason |
| State machines | FlowState, ResourceState, InvalidTransition |
| Records | ElementMeta, TransferRecord, TraceContext |
| Traits | EventSink, NoopEventSink |
Structs§
- Buffer
Handle - Typed wrapper for buffer resources, built on
ResourceId. - Component
Instance Id - Runtime identity for a component instance within a host.
- Component
Type Id - Content-addressed identifier for a compiled component artifact.
- Element
Meta - Metadata accompanying each stream element.
- FlowId
- Unique identifier for a flow (pipeline execution instance).
- Invalid
Transition - Error returned when an illegal state transition is attempted.
- Noop
Event Sink - A no-op implementation of
EventSinkfor testing and benchmarking. - Resource
Id - Generational index into the resource table.
- SpanId
- W3C Trace Context span ID (64-bit / 8 bytes).
- Stream
Id - Unique identifier for a stream connection within the reactor.
- Trace
Context - W3C Trace Context carried through a flow for distributed tracing.
- TraceId
- W3C Trace Context trace ID (128-bit / 16 bytes).
- Transfer
Record - Record of a data transfer for copy accounting and observability.
Enums§
- Backpressure
Policy - Policy governing what happens when a stream queue is full.
- Backpressure
Signal - Backpressure signal from a consumer to the runtime.
- Component
Role - The role of a component within a pipeline topology.
- Config
Error - Configuration errors.
- Contract
Error - Contract validation errors.
- Copy
Reason - The reason a data copy occurred, for copy accounting and observability.
- Engine
Error - Engine errors for Wasm compilation and instantiation.
- Flow
State - Flow lifecycle state machine.
- Invocation
Status - Status of a component invocation, for observability recording.
- Link
Error - Component linking errors.
- Observability
Level - Observability collection level, configurable at runtime.
- Packaging
Error - Packaging and distribution errors.
- Process
Error - Rust mapping of the WIT
process-errorvariant. - Process
Error Kind - Lightweight variant tag for
ProcessError, used in observability paths where carrying the full error string is too expensive. - Reactor
Error - Reactor and scheduling errors.
- Resource
Error - Resource management errors.
- Resource
State - Resource ownership state machine.
- Security
Error - Security and capability errors.
- Severity
- Log severity level for diagnostic events.
- Torvyn
Error - Top-level error type aggregating all subsystem errors.
Constants§
- DEFAULT_
BUFFER_ POOL_ SIZE - Default buffer pool size per tier (number of buffers).
- DEFAULT_
COMPONENT_ TIMEOUT_ MS - Default component invocation timeout in milliseconds.
- DEFAULT_
COOPERATIVE_ CANCEL_ TIMEOUT_ MS - Default cooperative cancellation timeout in milliseconds.
- DEFAULT_
DRAIN_ TIMEOUT_ MS - Default drain timeout in milliseconds.
- DEFAULT_
ELEMENTS_ PER_ YIELD - Default elements per yield at Normal priority.
- DEFAULT_
LOW_ WATERMARK_ RATIO - Default low watermark ratio for backpressure recovery.
- DEFAULT_
QUEUE_ DEPTH - Default stream queue depth.
- MAX_
BUFFER_ SIZE_ BYTES - Maximum buffer size in bytes (global cap).
- MAX_
CONSECUTIVE_ ELEMENTS_ BEFORE_ YIELD - Default maximum consecutive elements before a flow driver must yield.
- MAX_
HOT_ PATH_ NS - Maximum allowed per-element host-side overhead in nanoseconds.
- MAX_
OBSERVABILITY_ DIAGNOSTIC_ NS - Maximum allowed observability overhead at Diagnostic level, in nanoseconds.
- MAX_
OBSERVABILITY_ PRODUCTION_ NS - Maximum allowed observability overhead at Production level, in nanoseconds.
- MIN_
COMPATIBLE_ VERSION - The minimum compatible Torvyn version for artifacts. Artifacts produced by versions older than this cannot be loaded.
- TORVYN_
VERSION - The current Torvyn runtime version (semver).
Traits§
- Event
Sink - The hot-path trait for recording observability events.
Functions§
- current_
timestamp_ ns - Returns the current wall-clock time as nanoseconds since the Unix epoch.
Type Aliases§
- Component
Id - Type alias for
ComponentInstanceId.