Expand description
§Storage Engine — NAP Asset Ingestion & Content-Addressed Storage
A unified storage abstraction over local-filesystem and S3-compatible backends (including Cloudflare R2, MinIO, and generic S3 providers).
§Architecture
The StorageEngine is initialised once (lazily via get_engine) and
reused across all FFI calls. The engine selects the backend at runtime
based on the NAP_STORAGE_BACKEND environment variable:
| Value | Backend | Required env vars |
|---|---|---|
local | Local filesystem | NAP_DIR (default: ~/.nap) |
s3 | S3-compatible object store | NAP_S3_BUCKET, AWS creds |
§Gotchas Handled
- S3 Endpoint Parsing — The builder reads
AWS_ENDPOINT_URL_S3(and falls back toAWS_ENDPOINT_URL) for R2/MinIO compatibility. HTTP endpoints automatically enablewith_allow_http(true). - Cross-platform paths — All local paths use
PathBuf; never string concatenation with/or\. - Idempotency —
ingest_mediaissues a HEAD before PUT; if the object already exists, the write is skipped and the hash is returned immediately. - Gitignore — The local initialiser ensures
.nap-assets/is present in<NAP_DIR>/.gitignoreso raw binaries never enter the Git graph.
Structs§
- Storage
Config - Runtime configuration of the storage engine.
- Storage
Engine - Thread-safe, lazily-initialised storage engine.
Enums§
- Storage
Backend - Storage backend variant selected at runtime.
- Storage
Error - Unified error type for all storage operations.
Functions§
- get_
engine - Return a reference to the globally-initialised
StorageEngine.
Type Aliases§
- Storage
Result - Convenience alias for storage results.