iii-rust-sdk

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Rust SDK

Rust SDK

The native async Rust SDK for connecting workers to the iii engine via tokio.
用于通过tokio将工作进程连接到iii引擎的原生异步Rust SDK。

Documentation

文档

Install

安装

Add to
Cargo.toml
:
iii-sdk = { version = "0.10", features = ["otel"] }
添加到
Cargo.toml
iii-sdk = { version = "0.10", features = ["otel"] }

Key Types and Functions

核心类型与函数

ExportPurpose
register_worker(url, InitOptions)
Connect to the engine, returns
III
client
III::register_function(RegisterFunction::new(id, handler))
Register a sync function using the builder API
III::register_function(RegisterFunction::new_async(id, handler))
Register an async function using the builder API
III::register_function_with(msg, handler)
Two-arg convenience method for function registration
RegisterFunction
Builder with
.description()
and auto-generated request schemas via
schemars
III::register_trigger(type, function_id, config)
Bind a trigger to a function
III::trigger(TriggerRequest)
Invoke a function
TriggerAction::Void
Fire-and-forget invocation
TriggerAction::Enqueue { queue }
Durable async invocation
IIIError
Error type for handler failures
Streams
Helper for atomic stream CRUD
with_span
,
get_tracer
,
get_meter
OpenTelemetry (requires
otel
feature)
execute_traced_request
HTTP client with trace context propagation
导出内容用途
register_worker(url, InitOptions)
连接到引擎,返回
III
客户端
III::register_function(RegisterFunction::new(id, handler))
使用构建器API注册同步函数
III::register_function(RegisterFunction::new_async(id, handler))
使用构建器API注册异步函数
III::register_function_with(msg, handler)
用于函数注册的双参数便捷方法
RegisterFunction
带有
.description()
方法的构建器,可通过
schemars
自动生成请求schema
III::register_trigger(type, function_id, config)
将触发器绑定到函数
III::trigger(TriggerRequest)
调用函数
TriggerAction::Void
即发即弃式调用
TriggerAction::Enqueue { queue }
持久化异步调用
IIIError
处理器失败时的错误类型
Streams
用于原子流CRUD的辅助工具
with_span
,
get_tracer
,
get_meter
OpenTelemetry(需启用
otel
特性)
execute_traced_request
带有追踪上下文传播的HTTP客户端

Key Notes

核心注意事项

  • Add
    features = ["otel"]
    to
    Cargo.toml
    for OpenTelemetry support
  • Use
    RegisterFunction::new("id", handler)
    for sync handlers,
    RegisterFunction::new_async("id", handler)
    for async
  • Handler input types that derive
    schemars::JsonSchema
    get auto-generated request schemas
  • Chain
    .description("...")
    on
    RegisterFunction
    to document the function
  • Keep the tokio runtime alive (e.g.,
    tokio::time::sleep
    loop) for event processing
  • register_trigger
    returns
    Ok(())
    on success; propagate errors with
    ?
  • Cargo.toml
    中添加
    features = ["otel"]
    以获得OpenTelemetry支持
  • 同步处理器使用
    RegisterFunction::new("id", handler)
    ,异步处理器使用
    RegisterFunction::new_async("id", handler)
  • 派生
    schemars::JsonSchema
    的处理器输入类型会自动生成请求schema
  • RegisterFunction
    上链式调用
    .description("...")
    可为函数添加文档说明
  • 保持tokio运行时处于活跃状态(例如
    tokio::time::sleep
    循环)以处理事件
  • register_trigger
    成功时返回
    Ok(())
    ;使用
    ?
    传播错误

Pattern Boundaries

模式边界

  • For usage patterns and working examples, see
    iii-functions-and-triggers
  • For Node.js SDK, see
    iii-node-sdk
  • For Python SDK, see
    iii-python-sdk
  • 有关使用模式和示例,请查看
    iii-functions-and-triggers
  • Node.js SDK请查看
    iii-node-sdk
  • Python SDK请查看
    iii-python-sdk

When to Use

使用场景

  • Use this skill when the task is primarily about
    iii-rust-sdk
    in the iii engine.
  • Triggers when the request directly asks for this pattern or an equivalent implementation.
  • 当任务主要涉及iii引擎中的
    iii-rust-sdk
    时,使用此技能。
  • 当请求直接要求此模式或等效实现时触发。

Boundaries

边界限制

  • Never use this skill as a generic fallback for unrelated tasks.
  • You must not apply this skill when a more specific iii skill is a better fit.
  • Always verify environment and safety constraints before applying examples from this skill.
  • 切勿将此技能用作无关任务的通用回退方案。
  • 当更特定的iii技能更合适时,不得使用此技能。
  • 在应用此技能中的示例之前,务必验证环境和安全约束。