Skip to main content

prns_runtime/manifold/
mod.rs

1use crate::engine::InstantMillis;
2
3#[allow(async_fn_in_trait)]
4pub trait Host {
5    fn now(&self) -> InstantMillis;
6    async fn sleep_until(&self, deadline: InstantMillis);
7    fn fill_entropy(&mut self, bytes: &mut [u8]);
8}
9
10pub mod airtime;
11pub mod announce_pacer;
12pub mod duty_gate;
13pub mod grant;
14pub mod interface_seam;
15pub mod kernel;
16pub mod reconnect;
17pub mod throughput;
18pub mod timers;
19
20pub(crate) mod window_ring;
21
22/// The app's synchronous judgment seams, consulted inline on the manifold: RNS 1.4.2 `PROVE_APP` and `ACCEPT_APP`.
23pub struct AppDeciders<P, A>
24where
25    P: FnMut(&prns_core::routing::proof::ProofRequest) -> bool,
26    A: FnMut(&prns_core::routing::links::resources::ResourceOffer) -> bool,
27{
28    pub should_prove: P,
29    pub should_accept_resource: A,
30}
31
32/// Every offer declined, every proof withheld: the posture of a manifold whose host installed no deciders.
33#[must_use]
34pub fn decline_all() -> AppDeciders<
35    impl FnMut(&prns_core::routing::proof::ProofRequest) -> bool,
36    impl FnMut(&prns_core::routing::links::resources::ResourceOffer) -> bool,
37> {
38    AppDeciders {
39        should_prove: |_| false,
40        should_accept_resource: |_| false,
41    }
42}