Skip to main content

Crate mnem_transport

Crate mnem_transport 

Source
Expand description

§mnem-transport

Offline transport for mnem: export a subtree of the content-addressed DAG to a CAR v1 archive, ship it anywhere (USB stick, email, scp, S3), import on the other side.

CAR (Content-Addressable aRchive) is IPFS’s standard bundling format: a stream of (varint length, CID, bytes) triples preceded by a varint-framed DAG-CBOR header that lists the root CIDs. It is streamable in both directions; this crate implements the CAR v1 wire shape exactly.

§Shape

  • export walks the Blockstore from a root CID via the Blockstore::iter_from_root default impl, writing every reachable block to a std::io::Write.
  • import reads a CAR from a std::io::Read and inserts every block into a target blockstore, verifying the CID on each block.
  • car exposes the lower-level CAR reader / writer used by the above, for callers that need to interleave CAR parsing with other work.

In addition to the file-format half, this crate is home to the shapes of mnem’s remote wire protocol:

Everything in those three modules is pure data + pure functions. HTTP wiring lives in mnem http; the CLI glue (mnem remote add etc.) lives in mnem-cli; neither lands until PR 3.

§Constraints

  • WASM-clean. No tokio, no async. The entire interface is std::io::{Read, Write} with ?Sized support.
  • No filesystem helpers; callers open files and pass the handles. Keeps this crate usable inside HTTP streams, pipes, etc.
  • Deterministic ordering: export writes blocks in iter_from_root’s depth-first order so the same root produces a byte-identical CAR across runs.

Re-exports§

pub use error::ClientError;
pub use error::TransportError;
pub use export::ExportStats;
pub use export::export;
pub use have_set::BloomHaveSet;
pub use have_set::HaveSet;
pub use have_set::build_have_set;
pub use import::ImportStats;
pub use import::import;
pub use protocol::CAPABILITIES_HEADER;
pub use protocol::Capability;
pub use protocol::CapabilitySet;
pub use protocol::PROTOCOL_HEADER;
pub use protocol::PROTOCOL_VERSION;
pub use protocol::parse_capabilities;
pub use protocol::serialize_capabilities;
pub use remote::RemoteConfig;
pub use remote::RemoteConfigFile;
pub use remote::RemoteSection;
pub use remote::parse_config;
pub use secret_token::SecretToken;
pub use client::HttpRemoteClient;
pub use client::PushResponse;
pub use client::RefsResponse;
pub use client::RemoteClient;

Modules§

car
CAR v1 reader + writer.
client
Async HTTP RemoteClient.
error
Transport-layer error type.
export
Export a reachable subtree of a Blockstore to CAR v1.
have_set
HaveSet trait and the PR-2 BloomHaveSet reference implementation.
import
Import a CAR v1 archive into a Blockstore.
protocol
Wire-level protocol constants and capability vocabulary for mnem’s remote transport.
remote
RemoteConfig and the .mnem/config.toml [remote.<name>] schema.
secret_token
Opaque bearer-token newtype used by the remote transport.

Constants§

VERSION
Library version (tracks the workspace package version).