Skip to main content

Installation

Initialization

register_worker

Register the worker with a iii instance, returns a connected worker client. The WebSocket connection is established automatically in a dedicated background thread with its own tokio runtime. Call IIIClient::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. Signature
address
&str
required
WebSocket URL of the III engine (e.g. ws://localhost:49134).
options
InitOptions
required
Configuration for worker metadata and OTel.

Methods

register_trigger

Bind a trigger configuration to a registered function. Signature
input
RegisterTriggerInput
required
Trigger registration input with trigger_type, function_id, and config.

register_function

Register a function with the engine. Argument order matches the Node and Python SDKs: (id, registration). Signature
id
impl Into<String>
required
Unique identifier for the function.
registration
RegisterFunction
required
Built via [RegisterFunction::new], [RegisterFunction::new_async], or [RegisterFunction::http]. Chain .description(...), .metadata(...), .request_format(...), .response_format(...) as needed.

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
request
impl Into<TriggerRequestWithMetadata>
required

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
trigger_type
RegisterTriggerType<H, C, R>
required

unregister_trigger_type

Unregister a previously registered trigger type. Signature
id
impl Into<String>
required

get_connection_state

Get the current connection state. Signature

Example


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. OpenTelemetry is flushed inside the connection thread before it exits. Signature

Example


shutdown_async

Shutdown the III client. This stops the connection loop and sends a shutdown signal, but it does not join connection_thread. This method returns without waiting for run_connection() to finish, making it safe to call from an async context without stalling the executor; shutdown blocks and joins the thread. The OpenTelemetry flush (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

Example

Types

iii_sdk

EnqueueResult · InitOptions · RegisterFunction · RegisterTriggerType · TelemetryOptions

EnqueueResult

Result returned when a function is invoked with TriggerAction.Enqueue.

InitOptions

Configuration options passed to register_worker.

RegisterFunction

Function registration builder. The function ID is supplied separately at registration time via IIIClient::register_function, RegisterFunction only carries the handler and optional metadata. Constructors:
  • RegisterFunction::new: sync function. Accepts both typed handlers (schemas auto-extracted via schemars) and Fn(Value, Option<Value>) -> Result<Value, Error> closures. The second argument is the per-invocation metadata sidecar and is None when absent.
  • RegisterFunction::new_async: async equivalent of new.
  • RegisterFunction::http: function invoked over HTTP (Lambda, Cloudflare Workers, etc.).
Builder methods (all consume self):
  • description
  • metadata
  • request_format: overrides any auto-extracted schema.
  • response_format: overrides any auto-extracted schema.

RegisterTriggerType

Builder for registering a custom trigger type with optional format schemas. Type parameters:
  • C tracks the trigger registration type (set via .trigger_request_format::<T>())
  • R tracks the call request type (set via .call_request_format::<T>())
Both default to Value (untyped) and change when the respective builder method is called. This allows IIIClient::register_trigger_type to return a TriggerTypeRef<C, R> with compile-time safety for both config and function input types.

TelemetryOptions

Worker metadata reported to the engine (language, framework, project).

iii_sdk::builtin_triggers

CronCallRequest · CronTriggerConfig · HttpCallRequest · HttpMethod · HttpTriggerConfig · LogCallRequest · LogLevel · LogTriggerConfig · QueueTriggerConfig · StateCallRequest · StateEventType · StateTriggerConfig · SubscribeTriggerConfig

CronCallRequest


CronTriggerConfig


HttpCallRequest


HttpMethod


HttpTriggerConfig


LogCallRequest


LogLevel


LogTriggerConfig


QueueTriggerConfig


StateCallRequest


StateEventType


StateTriggerConfig


SubscribeTriggerConfig

iii_sdk::channel

Channel · ChannelReader · ChannelWriter · StreamChannelRef

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.

StreamChannelRef

iii_sdk::channels

ChannelDirection · ChannelItem

ChannelDirection


ChannelItem

iii_sdk::engine

EngineFunctions · EngineTriggers

EngineFunctions

Engine function ids for internal operations.

EngineTriggers

Engine trigger ids.

iii_sdk::errors

Error · InvocationError

Error

Errors returned by the III SDK.

InvocationError

Structured invocation failure, mirroring the Node and Python InvocationError. Produced from the Error::Remote variant via Error::invocation_error. function_id is None from that accessor because the wire Remote payload does not carry it.

iii_sdk::protocol

ErrorBody · FunctionMessage · Message · RegisterFunctionMessage · RegisterTriggerInput · RegisterTriggerMessage · RegisterTriggerTypeMessage · TriggerAction · TriggerRequest · TriggerRequestWithMetadata · UnregisterTriggerMessage · UnregisterTriggerTypeMessage

ErrorBody


FunctionMessage


Message


RegisterFunctionMessage


RegisterTriggerInput

Input for IIIClient::register_trigger. The id is auto-generated internally.

RegisterTriggerMessage


RegisterTriggerTypeMessage


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.

TriggerRequest

Request object for trigger().

TriggerRequestWithMetadata

Trigger request plus optional per-invocation metadata.

UnregisterTriggerMessage


UnregisterTriggerTypeMessage

iii_sdk::runtime

FunctionInfo · FunctionRef · IIIConnectionState · TriggerInfo · TriggerTypeRef · WorkerInfo · WorkerMetadata

FunctionInfo

Function information returned by engine::functions::list

FunctionRef


IIIConnectionState

Connection state for the III WebSocket client

TriggerInfo

Trigger information returned by engine::triggers::list

TriggerTypeRef

Typed handle returned by IIIClient::register_trigger_type. Type parameters:
  • C: trigger registration type for register_trigger
  • R: call request type for register_function

WorkerInfo

Worker information returned by engine::workers::list

WorkerMetadata

Worker metadata for auto-registration

iii_sdk::stream_provider

IStream

IStream

Custom stream-provider trait. Implementors override the engine’s built-in stream storage for a specific stream name when registered through create_stream in the helpers submodule.

iii_sdk::structs

MiddlewareFunctionInput

MiddlewareFunctionInput

Input passed to the RBAC middleware function on every function invocation through the RBAC port. The middleware can inspect, modify, or reject the call before it reaches the target function.

iii_sdk::trigger

IIITrigger · Trigger · TriggerConfig · TriggerHandler

IIITrigger

Enum of all built-in trigger types with typed configuration. Use .for_function() to create a RegisterTriggerInput:

Trigger

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

TriggerConfig

Configuration passed to a TriggerHandler when a trigger instance is registered or unregistered.

TriggerHandler

Handler trait for custom trigger types. Implement this and pass to IIIClient::register_trigger_type.

iii_sdk::types

RemoteFunctionData · RemoteFunctionHandler · RemoteTriggerTypeData · StreamRequest · StreamResponse

RemoteFunctionData


RemoteFunctionHandler

A dispatchable function handler. Receives the invocation payload. Handlers that also want the optional per-invocation metadata sidecar use RemoteFunctionHandlerWithMetadata; this single-argument shape is kept for backward compatibility.

RemoteTriggerTypeData


StreamRequest

Incoming streaming request received by a function registered with a stream trigger. Alias of iii_helpers::http::HttpRequest.

StreamResponse

Streaming response type, mirroring the Node and Python StreamResponse. Alias of iii_helpers::http::HttpResponse; added for cross-language parity.