lib

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

publication.rs (3422B)


      1 //! Exact publication scope. Values describe retained work; they do not grant
      2 //! a writer lease, transport permission or proof of a committed row.
      3 use super::{
      4     EvidenceReceipt, OperationError, PublicPublicationWork, PublicationWork, SigningTarget,
      5 };
      6 use core::fmt;
      7 use radroots_domain::{PublicKey, TransactionId, UnixSeconds};
      8 
      9 /// One actual installed artifact's pending publication work. A public event has
     10 /// no private participant or wrapping identity.
     11 #[derive(Clone, Copy, Eq, PartialEq)]
     12 pub enum PublicationArtifact {
     13     /// Original private seal work, published through its verified outer carrier.
     14     Private(PublicationWork),
     15     /// Original public signed event, published directly without another signer.
     16     Public(PublicPublicationWork),
     17 }
     18 impl PublicationArtifact {
     19     /// Actual original captured artifact selection.
     20     pub const fn target(self) -> SigningTarget {
     21         self.evidence().target()
     22     }
     23     /// Actual private participant, absent for public work.
     24     pub const fn recipient(self) -> Option<PublicKey> {
     25         self.target().recipient()
     26     }
     27     /// Private-only projection; absence never becomes a synthetic participant.
     28     pub fn private(self) -> Result<PublicationWork, OperationError> {
     29         match self {
     30             Self::Private(v) => Ok(v),
     31             Self::Public(_) => Err(OperationError::UnsupportedOperation),
     32         }
     33     }
     34     /// Public-only projection without a private carrier fallback.
     35     pub fn public(self) -> Result<PublicPublicationWork, OperationError> {
     36         match self {
     37             Self::Public(v) => Ok(v),
     38             Self::Private(_) => Err(OperationError::UnsupportedOperation),
     39         }
     40     }
     41     /// Original installed business transaction, separate from transport.
     42     pub const fn installation_transaction_id(self) -> TransactionId {
     43         match self {
     44             Self::Private(v) => v.installation_transaction_id(),
     45             Self::Public(v) => v.installation_transaction_id(),
     46         }
     47     }
     48     /// Original complete signing plan and its captured publication inputs.
     49     pub const fn plan_digest(&self) -> &[u8; 32] {
     50         match self {
     51             Self::Private(v) => v.plan_digest(),
     52             Self::Public(v) => v.plan_digest(),
     53         }
     54     }
     55     /// Original exact obtained artifact reference.
     56     pub const fn evidence(self) -> EvidenceReceipt {
     57         match self {
     58             Self::Private(v) => v.evidence(),
     59             Self::Public(v) => v.evidence(),
     60         }
     61     }
     62     /// Original pending-work retention transaction.
     63     pub const fn transaction_id(self) -> TransactionId {
     64         match self {
     65             Self::Private(v) => v.transaction_id(),
     66             Self::Public(v) => v.transaction_id(),
     67         }
     68     }
     69     /// Original queued observation, never a renewed dispatch deadline.
     70     pub const fn queued_at(self) -> UnixSeconds {
     71         match self {
     72             Self::Private(v) => v.queued_at(),
     73             Self::Public(v) => v.queued_at(),
     74         }
     75     }
     76 }
     77 impl From<PublicationWork> for PublicationArtifact {
     78     fn from(v: PublicationWork) -> Self {
     79         Self::Private(v)
     80     }
     81 }
     82 impl From<PublicPublicationWork> for PublicationArtifact {
     83     fn from(v: PublicPublicationWork) -> Self {
     84         Self::Public(v)
     85     }
     86 }
     87 impl fmt::Debug for PublicationArtifact {
     88     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     89         f.write_str("PublicationArtifact(<redacted>)")
     90     }
     91 }