Skip to main content

spacedb_meter/
lib.rs

1#![forbid(unsafe_code)]
2//! # spacedb-meter — SpaceDB Layer 6 (metering & settlement)
3//!
4//! SpaceDB **measures**; it does not price or pay. This crate computes the three
5//! resource amounts deterministically — storage ([`Usage::storage`], bytes × time ×
6//! replica_count), compute ([`Usage::compute`], fuel + invocations), and transit
7//! ([`Usage::transit`], bilaterally-corroborated served bytes) — accumulates them
8//! in a [`MeterLedger`], and drains them into amounts-only [`UsageClaim`]s.
9//!
10//! Pricing ([`RateCard`]), the agent spend cap ([`Budget`]), and pre-deploy cost
11//! estimates are open-core too. **Settlement is the seam**: the bundled
12//! [`LocalSettlement`] is enough for a self-hoster, while a host implements
13//! [`Settlement`] over its own money plane — for MATA that is the existing
14//! `UsageClaim → Maestro counter-sign → EarningRecord → Iron Bank` loop — so
15//! SpaceDB usage settles through it without ever depending on it.
16//!
17//! Open-core (MIT). No `spacedb-*` / `mata-*` dependencies.
18
19mod error;
20pub use error::{MeterError, MeterResult};
21
22mod usage;
23pub use usage::{ProofKind, ProofRef, Resource, Usage};
24
25mod claim;
26pub use claim::UsageClaim;
27
28mod ratecard;
29pub use ratecard::RateCard;
30
31mod budget;
32pub use budget::Budget;
33
34mod ledger;
35pub use ledger::{MeterLedger, Totals};
36
37mod settle;
38pub use settle::{LocalSettlement, Settled, Settlement};
39
40/// Compiles the README's examples as doctests, so the documented API can never
41/// drift from the real one. Not part of the public API, and not rendered into
42/// the crate docs — it exists only under `cargo test --doc`.
43#[cfg(doctest)]
44#[doc = include_str!("../README.md")]
45pub struct ReadmeDoctests;