Skip to main content

Installation

cargo add iii-helpers
API reference for the iii-helpers crate (Rust).

http

HTTP request/response types, auth config, and the http helper. Import
use iii_helpers::http;

Types

HttpAuthConfig · HttpInvocationConfig · HttpMethod · HttpRequest · HttpResponse

HttpAuthConfig

Authentication configuration for HTTP-invoked functions.
  • Hmac — HMAC signature verification using a shared secret.
  • Bearer — Bearer token authentication.
  • ApiKey — API key sent via a custom header.
NameTypeRequiredDescription
Hmac{ secret_key: String }Yes-
Bearer{ token_key: String }Yes-
ApiKey{ header: String, value_key: String }Yes-

HttpInvocationConfig

Configuration for registering an HTTP-invoked function (Lambda, Cloudflare Workers, etc.) instead of a local handler.
NameTypeRequiredDescription
urlStringYes-
methodHttpMethodYes-
timeout_msOption<u64>No-
headersHashMap<String, String>Yes-
authOption<HttpAuthConfig>No-

HttpMethod

HTTP method accepted by HttpInvocationConfig. Distinct from the core builtin_triggers HTTP method enum, which also covers HEAD/OPTIONS.
NameTypeRequiredDescription
GetunitYes-
PostunitYes-
PutunitYes-
PatchunitYes-
DeleteunitYes-

HttpRequest

Buffered HTTP request received by a function handler.
NameTypeRequiredDescription
query_paramsHashMap<String, String>Yes-
path_paramsHashMap<String, String>Yes-
headersHashMap<String, String>Yes-
pathStringYes-
methodStringYes-
bodyTYes-

HttpResponse

Buffered HTTP response returned from a function handler.
NameTypeRequiredDescription
status_codeu16Yes-
headersHashMap<String, String>Yes-
bodyTYes-

observability

Logger, OpenTelemetry config, and span helpers. Import
use iii_helpers::observability;

Types

BaggageSpanProcessor · CapturedContext · ConnectionState · EngineLogExporter · EngineMetricsExporter · EngineSpanExporter · Logger · OtelConfig · OtelMessage · ReconnectionConfig · SharedEngineConnection · WorkerGaugesHandle · WorkerGaugesOptions · WorkerMetrics · WorkerMetricsCollector

BaggageSpanProcessor

CapturedContext

Snapshot of the current OTel context for use across tokio::spawn. tokio::spawn does NOT carry OTel context into the spawned task; without this, child spans become orphan roots. Capture before spawn, then call .attach(future) inside the spawned block.

ConnectionState

Connection state for the shared WebSocket
NameTypeRequiredDescription
DisconnectedunitYes-
ConnectingunitYes-
ConnectedunitYes-
ReconnectingunitYes-
FailedunitYes-

EngineLogExporter

Custom log exporter that sends OTLP JSON over a shared WebSocket connection. Uses a hand-built JSON serializer to match the III Engine’s expected format.

EngineMetricsExporter

Custom metrics exporter that sends OTLP JSON over a shared WebSocket connection. Uses a hand-built JSON serializer to match the III Engine’s expected format.

EngineSpanExporter

Custom span exporter that sends OTLP JSON over a shared WebSocket connection. Uses a hand-built JSON serializer (not opentelemetry-proto serde) to match the format the III Engine expects: camelCase field names, integer attribute values as JSON numbers, and hex-encoded trace/span IDs.

Logger

Structured logger that emits logs as OpenTelemetry LogRecords. Every log call automatically captures the active trace and span context, correlating your logs with distributed traces without any manual wiring. When OTel is not initialized, Logger gracefully falls back to the tracing crate. Pass structured data as the second argument to any log method. Using a serde_json::Value object of key-value pairs (instead of string interpolation) lets you filter, aggregate, and build dashboards in your observability backend.

OtelConfig

Configuration for OpenTelemetry initialization
NameTypeRequiredDescription
enabledOption<bool>No-
service_nameOption<String>No-
service_versionOption<String>No-
service_namespaceOption<String>No-
service_instance_idOption<String>No-
engine_ws_urlOption<String>No-
metrics_enabledOption<bool>No-
metrics_export_interval_msOption<u64>No-
reconnection_configOption<ReconnectionConfig>No-
shutdown_timeout_msOption<u64>NoTimeout in milliseconds for the shutdown sequence (default: 10,000)
channel_capacityOption<usize>NoCapacity of the internal telemetry message channel (default: 10,000).
This controls the in-flight message buffer between exporters and the
WebSocket connection loop. Intentionally larger than
ReconnectionConfig::max_pending_messages to absorb bursts during
normal operation while limiting stale data across reconnects.
spans_flush_interval_msOption<u64>NoSpan processor flush delay in milliseconds. Defaults to 100ms when not
set. The OpenTelemetry default of 5000ms is what makes traces appear
seconds after the action. Env override: OTEL_SPANS_FLUSH_INTERVAL_MS.
logs_enabledOption<bool>NoWhether to enable the log exporter (default: true)
logs_flush_interval_msOption<u64>NoLog processor flush delay in milliseconds. Defaults to 100ms when not set.
logs_batch_sizeOption<usize>NoMaximum number of log records exported per batch. Defaults to 1 when not set.
fetch_instrumentation_enabledOption<bool>NoWhether to auto-instrument outgoing HTTP calls.
When Some(true) (default), execute_traced_request() can be used to
create CLIENT spans for reqwest requests. Set Some(false) to opt out.
None is treated as true.

OtelMessage

Message to send over the shared WebSocket connection
NameTypeRequiredDescription
prefix&'static [u8]Yes-
dataVec<u8>Yes-

ReconnectionConfig

Configuration for WebSocket reconnection behavior
NameTypeRequiredDescription
initial_delay_msu64Yes-
max_delay_msu64Yes-
backoff_multiplierf64Yes-
jitter_factorf64Yes-
max_retriesOption<u64>No-
max_pending_messagesusizeYesMaximum messages preserved across reconnects. Messages beyond this limit
are dropped to prevent delivering stale data after a long disconnect.
This is intentionally smaller than OtelConfig::channel_capacity (the
in-flight buffer between exporters and the WebSocket loop).

SharedEngineConnection

Shared WebSocket connection for all OTEL exporters

WorkerGaugesHandle

Handle that keeps the OTEL gauges alive. Drop to stop reporting.

WorkerGaugesOptions

Options for registering worker gauges
NameTypeRequiredDescription
worker_idStringYes-
worker_nameOption<String>No-

WorkerMetrics

Collected worker metrics snapshot
NameTypeRequiredDescription
memory_rssu64Yes-
memory_virtualu64Yes-
cpu_percentf32Yes-
uptime_secondsf64Yes-
timestamp_msu64Yes-
runtime&'static strYes-

WorkerMetricsCollector

Collects system metrics for the current process

queue

Queue enqueue result types. Import
use iii_helpers::queue;

Types

EnqueueResult

EnqueueResult

Result returned by the engine when a message is successfully enqueued.
NameTypeRequiredDescription
message_receipt_idStringYes-

stream

Stream trigger configs, change events, IO inputs, and update operations. Import
use iii_helpers::stream;

Types

MergePath · StreamAuthInput · StreamAuthResult · StreamChangeEvent · StreamChangeEventDetail · StreamDeleteInput · StreamDeleteResult · StreamEventType · StreamGetInput · StreamJoinLeaveEvent · StreamJoinLeaveTriggerConfig · StreamJoinResult · StreamListGroupsInput · StreamListInput · StreamSetInput · StreamSetResult · StreamTriggerConfig · StreamUpdateInput · StreamUpdateResult · UpdateOp · UpdateOpError

MergePath

Path target for a UpdateOp::Merge operation. Accepts either a single string (legacy / first-level field) or an array of literal segments (nested path). Path normalization rules applied by the engine:
  • absent / Single("") / Segments(vec![]) → root merge
  • Single("foo") is equivalent to Segments(vec!["foo".into()])
  • Segments(["a", "b", "c"]) walks three literal keys, never interpreting dots specially. Segments(vec!["a.b".into()]) is a single literal key named "a.b".
Variant ordering is load-bearing. #[serde(untagged)] tries variants in declaration order, Single MUST come before Segments so a JSON string deserializes into Single rather than failing the array match first.
NameTypeRequiredDescription
Single(String)Yes-
Segments(Vec<String>)Yes-

StreamAuthInput

Input for stream authentication.
NameTypeRequiredDescription
headersHashMap<String, String>Yes-
pathStringYes-
query_paramsHashMap<String, Vec<String>>Yes-
addrStringYes-

StreamAuthResult

Result of stream authentication.
NameTypeRequiredDescription
contextOption<Value>No-

StreamChangeEvent

Handler input for stream triggers, fired when an item changes via stream::set, stream::update, or stream::delete.
NameTypeRequiredDescription
event_typeStringYesAlways "stream".
timestampi64YesUnix timestamp (milliseconds) of the event.
stream_nameStringYesThe stream where the change occurred.
group_idStringYesThe group where the change occurred.
idOption<String>NoThe item ID that changed.
eventStreamChangeEventDetailYesThe event detail containing mutation type and data.

StreamChangeEventDetail

Detail of a stream change event containing the mutation type and data.
NameTypeRequiredDescription
event_typeStreamEventTypeYesThe kind of mutation (create, update, or delete).
dataValueYesThe data associated with the event.

StreamDeleteInput

Input for deleting a stream item.
NameTypeRequiredDescription
stream_nameStringYes-
group_idStringYes-
item_idStringYes-

StreamDeleteResult

NameTypeRequiredDescription
old_valueOption<Value>NoThe value before the update (None if key didn’t exist)

StreamEventType

The kind of mutation that occurred on a stream item.
NameTypeRequiredDescription
CreateunitYes-
UpdateunitYes-
DeleteunitYes-

StreamGetInput

Input for retrieving a single stream item.
NameTypeRequiredDescription
stream_nameStringYes-
group_idStringYes-
item_idStringYes-

StreamJoinLeaveEvent

Event payload for stream join/leave triggers.
NameTypeRequiredDescription
subscription_idStringYes-
stream_nameStringYes-
group_idStringYes-
idOption<String>No-
contextOption<Value>No-

StreamJoinLeaveTriggerConfig

Trigger config for stream:join and stream:leave triggers.
NameTypeRequiredDescription
stream_nameOption<String>NoStream name to watch
condition_function_idOption<String>NoOptional function ID to evaluate before invoking handler

StreamJoinResult

Result of a stream join request.
NameTypeRequiredDescription
unauthorizedboolYes-

StreamListGroupsInput

Input for listing all groups in a stream.
NameTypeRequiredDescription
stream_nameStringYes-

StreamListInput

Input for listing all items in a stream group.
NameTypeRequiredDescription
stream_nameStringYes-
group_idStringYes-

StreamSetInput

Input for setting a stream item.
NameTypeRequiredDescription
stream_nameStringYes-
group_idStringYes-
item_idStringYes-
dataValueYes-

StreamSetResult

NameTypeRequiredDescription
old_valueOption<Value>NoThe value before the update (None if key didn’t exist)
new_valueValueYesThe value after the update

StreamTriggerConfig

Trigger config for stream triggers. Filters which item changes fire the handler.
NameTypeRequiredDescription
stream_nameOption<String>NoStream name to watch
group_idOption<String>NoGroup ID filter
item_idOption<String>NoItem ID filter
condition_function_idOption<String>NoOptional function ID to evaluate before invoking handler

StreamUpdateInput

Input for atomically updating a stream item.
NameTypeRequiredDescription
stream_nameStringYes-
group_idStringYes-
item_idStringYes-
opsVec<UpdateOp>Yes-

StreamUpdateResult

Result of an atomic update operation
NameTypeRequiredDescription
old_valueOption<Value>NoThe value before the update (None if key didn’t exist)
new_valueValueYesThe value after the update
errorsVec<UpdateOpError>YesErrors encountered while applying ops. Successfully applied ops
are still reflected in new_value. Field is omitted from JSON
when empty for backward compatibility.

UpdateOp

Operations that can be performed atomically on a stream value
NameTypeRequiredDescription
Set{ path: String, value: Option<Value> }YesSet a value at path (overwrite)
Merge{ path: Option<MergePath>, value: Value }YesMerge object into existing value (object-only). Path may be
omitted (root merge), a single first-level key, or an array of
literal segments for nested merge. See MergePath.
Increment{ path: String, by: i64 }YesIncrement numeric value
Decrement{ path: String, by: i64 }YesDecrement numeric value
Append{ path: Option<MergePath>, value: Value }YesAppend an element to an array or concatenate a string at the
optional path. Path may be omitted (root append), a single
first-level key, or an array of literal segments for nested
append. See MergePath for the variant shape.
Remove{ path: String }YesRemove a field

UpdateOpError

Per-op error reported by an atomic update operation.
NameTypeRequiredDescription
op_indexusizeYesIndex of the offending op within the original ops array.
codeStringYesStable error code, e.g. "merge.path.too_deep".
messageStringYesHuman-readable description with concrete numbers when applicable.
doc_urlOption<String>NoOptional documentation URL for this error class.

worker_connection_manager

RBAC auth and registration callback types. Import
use iii_helpers::worker_connection_manager;

Types

AuthInput · AuthResult · OnFunctionRegistrationInput · OnFunctionRegistrationResult · OnTriggerRegistrationInput · OnTriggerRegistrationResult · OnTriggerTypeRegistrationInput · OnTriggerTypeRegistrationResult

AuthInput

Input passed to the RBAC auth function during WebSocket upgrade. Contains the HTTP headers, query parameters, and client IP from the connecting worker’s upgrade request.
NameTypeRequiredDescription
headersHashMap<String, String>YesHTTP headers from the WebSocket upgrade request.
query_paramsHashMap<String, Vec<String>>YesQuery parameters from the upgrade URL. Each key maps to a vec of values
to support repeated keys (e.g. ?a=1&a=2).
ip_addressStringYesIP address of the connecting client.

AuthResult

Return value from the RBAC auth function. Controls which functions the authenticated worker can invoke and what context is forwarded to the middleware.
NameTypeRequiredDescription
allowed_functionsVec<String>YesAdditional function IDs to allow beyond the expose_functions config.
forbidden_functionsVec<String>YesFunction IDs to deny even if they match expose_functions.
Takes precedence over allowed.
allowed_trigger_typesOption<Vec<String>>NoTrigger type IDs the worker may register triggers for.
When None, all types are allowed.
allow_trigger_type_registrationboolYesWhether the worker may register new trigger types. Defaults to false.
allow_function_registrationboolYesWhether the worker may register new functions. Defaults to true.
contextValueYesArbitrary context forwarded to the middleware function on every
invocation.
function_registration_prefixOption<String>NoOptional prefix applied to all function IDs registered by this worker.

OnFunctionRegistrationInput

Input passed to the on_function_registration_function_id hook when a worker attempts to register a function through the RBAC port. Return an OnFunctionRegistrationResult with the (possibly mapped) fields, or return an error to deny the registration.
NameTypeRequiredDescription
function_idStringYesID of the function being registered.
descriptionOption<String>NoHuman-readable description of the function.
metadataOption<Value>NoArbitrary metadata attached to the function.
contextValueYesAuth context from AuthResult.context for this session.

OnFunctionRegistrationResult

Result returned from the on_function_registration_function_id hook. Omitted fields keep the original value from the registration request.
NameTypeRequiredDescription
function_idOption<String>NoMapped function ID.
descriptionOption<String>NoMapped description.
metadataOption<Value>NoMapped metadata.

OnTriggerRegistrationInput

Input passed to the on_trigger_registration_function_id hook when a worker attempts to register a trigger through the RBAC port. Return an OnTriggerRegistrationResult with the (possibly mapped) fields, or return an error to deny the registration.
NameTypeRequiredDescription
trigger_idStringYesID of the trigger being registered.
trigger_typeStringYesTrigger type identifier.
function_idStringYesID of the function this trigger is bound to.
configValueYesTrigger-specific configuration.
metadataOption<Value>NoArbitrary metadata attached to the trigger.
contextValueYesAuth context from AuthResult.context for this session.

OnTriggerRegistrationResult

Result returned from the on_trigger_registration_function_id hook. Omitted fields keep the original value from the registration request.
NameTypeRequiredDescription
trigger_idOption<String>NoMapped trigger ID.
trigger_typeOption<String>NoMapped trigger type.
function_idOption<String>NoMapped function ID.
configOption<Value>NoMapped trigger configuration.

OnTriggerTypeRegistrationInput

Input passed to the on_trigger_type_registration_function_id hook when a worker attempts to register a new trigger type through the RBAC port. Return an OnTriggerTypeRegistrationResult with the (possibly mapped) fields, or return an error to deny the registration.
NameTypeRequiredDescription
trigger_type_idStringYesID of the trigger type being registered.
descriptionStringYesHuman-readable description of the trigger type.
contextValueYesAuth context from AuthResult.context for this session.

OnTriggerTypeRegistrationResult

Result returned from the on_trigger_type_registration_function_id hook. Omitted fields keep the original value from the registration request.
NameTypeRequiredDescription
trigger_type_idOption<String>NoMapped trigger type ID.
descriptionOption<String>NoMapped description.