Rust

The daemon-binding Rust crate in ant-sdk is antd-client. It is separate from the native Rust ant-core route documented elsewhere in this docs set.

Install

cargo add antd-client

Connect to the daemon

use antd_client::{Client, DEFAULT_BASE_URL, discover_daemon_url};
use std::time::Duration;

// Default REST client
let client = Client::new(DEFAULT_BASE_URL);

// Use discovered URL if available
let discovered = discover_daemon_url().unwrap_or_else(|| DEFAULT_BASE_URL.to_string());
let discovered_client = Client::new(&discovered);

// Custom timeout
let slow_client = Client::with_timeout(DEFAULT_BASE_URL, Duration::from_secs(30));

For gRPC, the current crate also exports GrpcClient and DEFAULT_GRPC_ENDPOINT.

Store and retrieve data

For upload examples in this section, start antd in a write-enabled mode first. On the default network, that means wallet plus EVM payment configuration. On a local devnet, ant dev start provisions that for you.

Type mappings

Autonomi type
Rust type

HealthStatus

antd_client::HealthStatus

PutResult

antd_client::PutResult

WalletAddress

antd_client::WalletAddress

WalletBalance

antd_client::WalletBalance

PrepareUploadResult

antd_client::PrepareUploadResult

FinalizeUploadResult

antd_client::FinalizeUploadResult

Raw data

Vec<u8> or &[u8]

Error handling

Full API reference

For all available daemon endpoints, see the REST API. For the native Rust interface, see Developing in Rust.

Last updated