Skip to main content

hypercall_runtime_api/
db_ports.rs

1//! Persistence trait aliases used by the API runtime and admin surfaces.
2//!
3//! These are blanket aliases over the stable `hypercall-db` and transaction
4//! submitter reader traits. They live in `hypercall-runtime-api` so the admin
5//! surface can hold `Arc<dyn ApiAsyncDb>` / `Arc<dyn ApiSyncDb>` without
6//! depending on `hypercall-api` internals.
7
8#[cfg(not(feature = "rsm-state"))]
9pub trait ApiRsmStateDb {}
10
11#[cfg(not(feature = "rsm-state"))]
12impl<T> ApiRsmStateDb for T {}
13
14#[cfg(feature = "rsm-state")]
15pub trait ApiRsmStateDb: hypercall_db::ValidatorRsmStateAsyncReader {}
16
17#[cfg(feature = "rsm-state")]
18impl<T> ApiRsmStateDb for T where T: hypercall_db::ValidatorRsmStateAsyncReader {}
19
20pub trait ApiAsyncDb:
21    ApiRsmStateDb
22    + hypercall_db::AnalyticsWriter
23    + hypercall_db::AsyncDirectiveOutboxReader
24    + hypercall_db::BootstrapReader
25    + hypercall_db::CatalogReader
26    + hypercall_db::FaucetWriter
27    + hypercall_db::IntegrityReader
28    + hypercall_db::LiquidationReader
29    + hypercall_db::PmSettlementProjectionReader
30    + hypercall_transaction_submitter_db::TransactionSubmitterReader
31{
32}
33
34impl<T> ApiAsyncDb for T where
35    T: ApiRsmStateDb
36        + hypercall_db::AnalyticsWriter
37        + hypercall_db::AsyncDirectiveOutboxReader
38        + hypercall_db::BootstrapReader
39        + hypercall_db::CatalogReader
40        + hypercall_db::FaucetWriter
41        + hypercall_db::IntegrityReader
42        + hypercall_db::LiquidationReader
43        + hypercall_db::PmSettlementProjectionReader
44        + hypercall_transaction_submitter_db::TransactionSubmitterReader
45{
46}
47
48pub trait ApiSyncDb:
49    hypercall_db::RfqWriter + hypercall_db::RsmCreditReader + hypercall_db::TierWriter
50{
51}
52
53impl<T> ApiSyncDb for T where
54    T: hypercall_db::RfqWriter + hypercall_db::RsmCreditReader + hypercall_db::TierWriter
55{
56}