> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tape.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust

`tape-sdk` is the native Rust SDK and the reference implementation. It lives in the core repository beside the programs and the node, on purpose: it is what the network's own end-to-end tests drive.

## Who this is for

* Rust services and backends.
* Authors of tooling around the node or the programs.
* Anyone who wants the reference implementation: everything documented anywhere in this section exists here first.

## Installation

```toml theme={null}
[dependencies]
tape-sdk = "0.4"
```

The crate is on [crates.io](https://crates.io/crates/tape-sdk). For unreleased changes, depend on `https://github.com/spool-labs/tape` with a git dependency and pin a rev.

## The client

`Tapedrive::new(rpc, payer)` gives you the full client: reads, writes, and lifecycle operations. `new_read_only(rpc)` is for consumers. `from_parts` is for callers assembling their own backends. Configuration is builder-style (`with_payer`, `with_metrics`), and the accessors (`rpc()`, the cached protocol `state()`, `payer()`) expose what the client holds.

The client is generic over its RPC backend and API transport. The same code runs against Solana in production and against in-memory backends in tests, which is how the node's multi-node simulations drive it ([built to be tested](/protocol/architecture/storage-nodes#built-to-be-tested)).

```rust theme={null}
use tape_sdk::Tapedrive;

let payer = read_keypair_file("~/.config/solana/id.json")?;
let client = Tapedrive::new(rpc, payer);
let reader = Tapedrive::new_read_only(rpc);
let gw = Tapedrive::new_gateway_read_only(rpc, GATEWAY_URL)?;
let instrumented = Tapedrive::new(rpc, payer).with_metrics(my_metrics);
```

## The modules

A tour by module. Per-method contracts live on [docs.rs](https://docs.rs/tape-sdk).

* **Writes**: `write` / `write_bytes` / `write_stream` and their `write_named` counterparts, size-dispatched, with `AsyncRead` sources for streams ([writing](/sdks/writing)). Track-level control: `write_track` / `write_named_track` / `write_raw` for callers choosing the path explicitly.
* **Reads**: `read_bytes` / `read_into` for whole content into a buffer or an `AsyncWrite` sink; track-level `read` and `verify` for commitment checks ([reading](/sdks/reading)).
* **Tape lifecycle**: `reserve` with the `estimate_cost` / `reservation_cost` / `remaining_epochs` pricing helpers; `get_tape`; `extend_expiry` / `extend_capacity` (permissionless); `set_tape_delegate` / `revoke_tape_delegate` ([tapes](/protocol/architecture/tapes)).
* **Tracks**: `get_track`, `get_track_by_number`, `find_track`, `list_tracks_by_tape`, `get_track_proof`, `delete` ([tracks](/protocol/architecture/tracks)).
* **Objects**: `put_object`, `get_object` / `get_object_into`, `head_object`, `list_objects` with the query builder (prefix, delimiter, cursor, limit), `delete_object` ([objects](/sdks/objects)).
* **Gateway**: the gateway-backed client for read-side consumers, constructed read-only against a gateway endpoint and exposing the same read methods ([gateway API](/apis/gateway)).
* **Stream**: the segment and manifest machinery under stream writes: manifest types, receipts, stream readers ([streams](/sdks/streams)).
* **Staking**: node and delegation staking operations ([token economics](/protocol/architecture/token-economics)).
* **Keys**: `TapeKey` and stake-key types with generation, persistence, and address derivation.
* **Codec, transfer, error, metrics**: on-chain state codecs, the slice upload/download and certify machinery behind writes, the `TapedriveError` type every method returns, and the metrics trait for instrumentation.

```rust theme={null}
// end to end, natively; every write path certifies before returning
let tape = TapeKey::generate();
let cost = client.estimate_cost(capacity, epochs).await?;
client.reserve(&tape, capacity, epochs).await?;

let track = client.put_object(&tape, "hello.txt", b"hello", Some("text/plain")).await?;

let listing = client.list_objects(&tape.address(), ListObjectsQuery::new("")).await?;
let bytes = client.get_object(&tape.address(), "hello.txt").await?;
```

## Certified writes

The crate performs the full certified-write orchestration itself: registration, slice distribution, BLS signature collection, certification. The [staged pipeline](/sdks/writing#the-staged-pipeline) walks those stages one by one, and the rule they enforce is on the [tracks page](/protocol/architecture/tracks): a coded write is finished when certified.
