lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

client_rewrap.rs (4940B)


      1 //! Client-owned explicit carrier work reuses commerce admission and shutdown.
      2 use super::{ClientSession, SessionHost, Shared};
      3 use crate::{
      4     Error, OperationContext,
      5     session::{command::RunMode, commerce::*},
      6     workspace::WorkspaceSession,
      7 };
      8 use alloc::boxed::Box;
      9 use radroots_domain::{CommandDigest, OperationId, PublicKey};
     10 use radroots_storage::{
     11     command::OperationError,
     12     inventory::{InventoryCheckpointRef, InventoryStore},
     13 };
     14 
     15 impl<H: SessionHost + 'static> ClientSession<H> {
     16     /// Requests one explicit additional outer for an actual original F10/S/T2.
     17     /// Only a newly confirmed admission can create its key. Repeating the same
     18     /// identity observes/resumes known bytes and never regenerates an unknown.
     19     #[allow(clippy::too_many_arguments)]
     20     pub async fn rewrap_stock_acceptance(
     21         &self,
     22         inventory: Shared<dyn InventoryStore>,
     23         store: Shared<dyn AcceptanceStore>,
     24         scope: &WorkspaceSession,
     25         minimum: InventoryCheckpointRef,
     26         operation: OperationId,
     27         digest: CommandDigest,
     28         recipient: PublicKey,
     29         id: OperationId,
     30     ) -> crate::ExecutionResult<AcceptanceRewrapStatus> {
     31         self.submit_rewrap(
     32             inventory,
     33             store,
     34             scope,
     35             minimum,
     36             operation,
     37             digest,
     38             recipient,
     39             id,
     40             RunMode::Command,
     41         )
     42         .await
     43     }
     44     /// Resumes a known exact outer using current scoped consent. No wrapping
     45     /// admission, temporary key or business signature is created by recovery.
     46     #[allow(clippy::too_many_arguments)]
     47     pub async fn resume_stock_rewrap(
     48         &self,
     49         inventory: Shared<dyn InventoryStore>,
     50         store: Shared<dyn AcceptanceStore>,
     51         scope: &WorkspaceSession,
     52         minimum: InventoryCheckpointRef,
     53         operation: OperationId,
     54         digest: CommandDigest,
     55         recipient: PublicKey,
     56         id: OperationId,
     57     ) -> crate::ExecutionResult<AcceptanceRewrapStatus> {
     58         self.submit_rewrap(
     59             inventory,
     60             store,
     61             scope,
     62             minimum,
     63             operation,
     64             digest,
     65             recipient,
     66             id,
     67             RunMode::Resume,
     68         )
     69         .await
     70     }
     71     #[allow(clippy::too_many_arguments)]
     72     async fn submit_rewrap(
     73         &self,
     74         inventory: Shared<dyn InventoryStore>,
     75         store: Shared<dyn AcceptanceStore>,
     76         scope: &WorkspaceSession,
     77         minimum: InventoryCheckpointRef,
     78         operation: OperationId,
     79         digest: CommandDigest,
     80         recipient: PublicKey,
     81         id: OperationId,
     82         mode: RunMode,
     83     ) -> crate::ExecutionResult<AcceptanceRewrapStatus> {
     84         self.submit_stock_commerce(
     85             scope,
     86             operation,
     87             mode,
     88             move |binding| {
     89                 Ok(AcceptanceSelection {
     90                     binding,
     91                     minimum,
     92                     operation,
     93                     digest,
     94                 })
     95             },
     96             move |selection, proof, runtime, resources| {
     97                 Box::pin(async move {
     98                     let runtime = runtime.ok_or_else(|| {
     99                         Error::operation(
    100                             OperationError::UnsupportedOperation,
    101                             OperationContext::retained(operation),
    102                         )
    103                     })?;
    104                     runtime
    105                         .run_stock_rewrap(
    106                             store, inventory, selection, &proof, resources, recipient, id, mode,
    107                         )
    108                         .await
    109                 })
    110             },
    111         )
    112         .await
    113     }
    114     /// Reads independent admission/capture/delivery facts with current access.
    115     /// An absent capture grants neither a fresh wrapping nor dispatch right.
    116     #[allow(clippy::too_many_arguments)]
    117     pub async fn stock_acceptance_rewrap_status(
    118         &self,
    119         inventory: Shared<dyn InventoryStore>,
    120         scope: &WorkspaceSession,
    121         minimum: InventoryCheckpointRef,
    122         operation: OperationId,
    123         digest: CommandDigest,
    124         recipient: PublicKey,
    125         id: OperationId,
    126     ) -> crate::Result<AcceptanceRewrapStatus> {
    127         self.run_stock(
    128             scope,
    129             OperationContext::retained(operation),
    130             move |binding, proof| {
    131                 Box::pin(async move {
    132                     rewrap_status(
    133                         &inventory,
    134                         &AcceptanceSelection {
    135                             binding,
    136                             minimum,
    137                             operation,
    138                             digest,
    139                         },
    140                         recipient,
    141                         id,
    142                         &proof,
    143                     )
    144                     .await
    145                 })
    146             },
    147         )
    148         .await
    149     }
    150 }