Skip to main content

Installation

Initialization

Create and return a connected SDK instance. The WebSocket connection is established automatically in a dedicated background thread with its own tokio runtime. Call [III::shutdown] before the end of main to cleanly stop the connection and join the background thread. In Rust the process exits when main returns, terminating all threads — so shutdown() must be called while main is still running.

Methods

set_headers

Set custom HTTP headers for the WebSocket handshake (call before connect). Signature

Parameters

shutdown

Shutdown the III client and wait for the connection thread to finish. This stops the connection loop, sends a shutdown signal, and joins the background connection thread. When the otel feature is enabled, telemetry is flushed inside the connection thread before it exits. Signature

shutdown_async

Shutdown the III client. This stops the connection loop and sends a shutdown signal, but it does not join connection_thread. Unlike shutdown, this method does not block to wait for run_connection() to finish, making it safe to call from an async context without stalling the executor. When the otel feature is enabled, telemetry::shutdown_otel() still runs inside the connection thread after run_connection() returns, so it may not complete unless shutdown is used to join the thread. Signature

register_function

Register a function with the engine. Pass a closure/async fn for local execution, or an [HttpInvocationConfig] for HTTP-invoked functions (Lambda, Cloudflare Workers, etc.). Signature

Parameters

Example

register_function_with

Register a function with a message and handler directly. Signature

Parameters

register_service

Register a service with the engine. Signature

Parameters

register_trigger_type

Register a custom trigger type with the engine. Returns a [TriggerTypeRef] handle that can register triggers and functions with compile-time validated types. Signature

Parameters

Example

unregister_trigger_type

Unregister a previously registered trigger type. Signature

Parameters

register_trigger

Bind a trigger configuration to a registered function. Signature

Parameters

Example

trigger

Invoke a remote function. The routing behavior depends on the action field of the request:
  • No action: synchronous — waits for the function to return.
  • [TriggerAction::Enqueue] - async via named queue.
  • [TriggerAction::Void] — fire-and-forget.
Signature

Parameters

Example

get_connection_state

Get the current connection state. Signature

create_channel

Create a streaming channel pair for worker-to-worker data transfer. Returns a Channel with writer, reader, and their serializable refs that can be passed as fields in invocation data to other functions. Signature

Parameters

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.

info

Log an info-level message. Signature

Parameters

Example

warn

Log a warning-level message. Signature

Parameters

Example

error

Log an error-level message. Signature

Parameters

Example

debug

Log a debug-level message. Signature

Parameters

Example

Types

InitOptions · IIIError · IIIConnectionState · TriggerRequest · TriggerAction · HttpInvocationConfig · HttpAuthConfig · HttpMethod · Channel · ChannelReader · ChannelWriter · ChannelDirection · StreamChannelRef · FunctionInfo · FunctionRef · TriggerInfo · WorkerInfo · WorkerMetadata · Trigger · RegisterFunctionMessage · RegisterServiceMessage · OtelConfig · ReconnectionConfig

InitOptions

Configuration options passed to [register_worker].

IIIError

Errors returned by the III SDK.

IIIConnectionState

Connection state for the III WebSocket client

TriggerRequest

Request object for trigger(). Matches the Node/Python SDK signature: trigger({ function_id, payload, action?, timeout_ms? })

TriggerAction

Routing action for [TriggerRequest]. Determines how the engine handles the invocation.
  • Enqueue — Routes through a named queue for async processing.
  • Void — Fire-and-forget, no response.

HttpInvocationConfig

Configuration for registering an HTTP-invoked function (Lambda, Cloudflare Workers, etc.) instead of a local handler.

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.

HttpMethod

Channel

A streaming channel pair for worker-to-worker data transfer.

ChannelReader

WebSocket-backed reader for streaming binary data and text messages.

ChannelWriter

WebSocket-backed writer for streaming binary data and text messages.

ChannelDirection

StreamChannelRef

FunctionInfo

Function information returned by engine::functions::list

FunctionRef

TriggerInfo

Trigger information returned by engine::triggers::list

WorkerInfo

Worker information returned by engine::workers::list

WorkerMetadata

Worker metadata for auto-registration

Trigger

Handle returned by III::register_trigger. Call unregister to remove the trigger from the engine.

RegisterFunctionMessage

RegisterServiceMessage

OtelConfig

Configuration for OpenTelemetry initialization

ReconnectionConfig

Configuration for WebSocket reconnection behavior