Expand description
IICP Rust client SDK — ADR-016 §1 (SDK-01..SDK-06)
§Quickstart
use iicp_client::{ChatMessage, ChatOptions, ClientConfig, IicpClient};
#[tokio::main]
async fn main() -> iicp_client::Result<()> {
let client = IicpClient::new(ClientConfig::default())?;
let reply = client.chat(
vec![ChatMessage { role: "user".into(), content: "What is IICP?".into() }],
None,
).await?;
println!("{}", reply.choices[0].message.content);
Ok(())
}Re-exports§
pub use qualify::qualify_service;pub use qualify::qualify_service_async;pub use qualify::ExposureMode;pub use qualify::ExposureQualification;pub use qualify::Ipv4Qualification;pub use qualify::Ipv6Qualification;pub use qualify::ServiceQualification;pub use node::IicpNode;pub use node::NodeConfig;pub use policy::classify_intent;pub use policy::ensure_intent_allowed;pub use policy::prohibited_intent_reason;pub use policy::IntentRiskCategory;pub use policy::ProhibitedIntentRule;pub use policy::HIGH_RISK_INTENT_RULES;pub use policy::POLICY_REFUSAL_CODE;pub use policy::PROHIBITED_INTENT_RULES;pub use routing_policy::filter_nodes_for_routing_policy;pub use routing_policy::resolved_policy;pub use routing_policy::routing_policy_refusal_message;pub use routing_policy::ROUTING_POLICY_REFUSAL_CODE;
Modules§
- availability
- Time-based availability windows — operator capacity shaping by time-of-day.
- backend_
stability - Provider-local backend stability observer and drain guard (#553).
- backends
- Drop-in backend handlers for iicp-client.
- cip_
policy - CIP-W01/CIP-W02 provider-side policy gate — S.12, ADR-012.
- concurrency
- Unified concurrency gate for the hybrid client.
- confidentiality
- IICP-CX S.16 Tier-1 confidentiality: X25519-HKDF-SHA256 + AES-256-GCM.
- conformance
- Self-conformance probes — operator-side health verification.
- consumer_
token - Directory-issued consumer token acquisition for Phase-2 task auth (#496).
- delegation
- ADR-045 Phase A — operator→node delegation (Ed25519).
- dispatch_
ticket - dispatch_
ticket_ trust - Opt-in verifier for the pre-normative dispatch-ticket trust v2 profile.
- idempotency
- Idempotency guard — task_id dedup with TTL eviction (parity Block E, #340).
- identity
- Persistent on-disk identity for the IICP Rust SDK CLI.
- iicp_
tcp - Native IICP binary transport (port 9484) — server + framing + cbor payloads.
- instance_
lock - #405 — single-instance lock per node_id.
- mcp_
policy - Fail-closed MCP tool-risk policy shared by the built-in gateway (#601).
- nat_
detection - UPnP NAT detection + dual-port mapping (ADR-041 tier-0 + tier-1).
- node
- IICP provider node — registration, heartbeats, and task serving.
- node_
log - Persistent node log writer —
~/.iicp/logs/<node-id>.log+events.jsonl. Used for registration, heartbeat, and deregistration events. - operator_
crypto - #460 — at-rest encryption of the operator secret (ed25519 seed) in
operator.json. - peer_
manager - Phase 2 mesh layer — peer discovery, gossip, and relay support (parity Block F, #340).
- policy
- Client-side policy guardrails.
- policy_
data_ handling - Opt-in evaluator for the pre-normative policy/data-handling profile.
- policy_
detail_ disclosure - Pre-normative provider-side policy-detail authorization and redaction.
- policy_
manifest - Local signed node-policy manifest producer (#588).
- policy_
operational_ evidence - Opt-in evaluator for pre-normative policy operational evidence.
- pricing
- ADR-019 declarative pricing + HMAC-SHA256 signing — provider-side.
- profile_
compatibility - Additive evaluator for the fixture-gated pre-normative profile draft.
- qualify
- ADR-043 §9/§11 — ServiceQualification: 8-category exposure enum + structured result.
- recovery
- Deterministic provider-node recovery signals.
- relay_
session - Relay-as-last-resort — ADR-041 tier-3, Part 3 R1 (#341).
- relay_
ticket - Directory-signed relay bind ticket helpers (#510 / DIR-RELAY-03).
- relay_
worker_ client - Relay worker client — ADR-041 tier-3, Part 3 R2 (#341).
- request_
projection - routing_
policy - Remote-routing policy gates for prompt dispatch (#585).
- scheduler
- QoS-aware admission policy for the provider serve path (parity Block C, #340).
- selection
- Opt-in, deterministic-testable
iicp.selection.v1candidate ordering. - service_
lifecycle - Opt-in reference adapter for the pre-normative service-lifecycle profile.
- service_
lifecycle_ accounting - Pure, opt-in accounting decisions for the draft service lifecycle profile.
- service_
lifecycle_ distributed - Portable evaluator for the pre-normative distributed lifecycle profile.
- service_
lifecycle_ identity - Production-identity projection policy for opt-in lifecycle operations.
- token_
validator - Constant-time bearer-token validation (parity Block E, #340).
- trust_
auditor - Trust auditor — cross-node declaration consistency check (parity Block E, #340).
- tunnel
- Quick-Tunnel escalation — #520 rung 5 of the NAT ladder. Rust port of iicp-client-python/tunnel.py (0f97ca1) and iicp-client-typescript/src/tunnel.ts (36456f2).
- updater
- Self-updater for provider nodes (#521 WQ-089). Rust parity with iicp-client-python/updater.py and -typescript/updater.ts.
Structs§
- Chat
Choice - A single choice in a chat response.
- Chat
Message - A single chat message (role + content).
- Chat
Options - Options for
chat()calls. - Chat
Response - OpenAI-compatible chat completion response.
- Chat
Usage - Token usage from a chat completion.
- Client
Config - Client configuration (SDK-04: timeout_ms enforced at construction time).
- CxPublic
Key - X25519 public key advertised by a CX-Provider node (IICP-CX S.16 §3.1).
- Discover
Options - Options for
discover()calls. - Iicp
Client - IICP client — discover → select → submit (ADR-016 §1).
- Node
- A single IICP node returned by
/v1/discover. - Node
List - Response from
/v1/discover. - Profile
Request - Route
Constraints - Prompt-free criteria used only for provider discovery and selection.
- Routing
Policy - Client-side pre-dispatch routing policy (#585).
- Task
Auth - Auth block for a task request.
- Task
Constraints - Constraints block for a task request.
- Task
Request - IICP task request body.
- Task
Response - Response from
POST /v1/task.
Enums§
- Iicp
Error - All errors emitted by the IICP client SDK.
- Routing
Profile - Client-side remote-routing profile (#585).
Functions§
- make_
traceparent - Generate a W3C traceparent header value (SDK-06).
Format:
00-<32hex>-<16hex>-01