clm-kernel 0.0.22

Cubical Logic Model (CLM) sovereign execution engine, CPN-VM, and Cordis spatiotemporal substrate
Documentation
//! Content storage contract consumed by lower-layer computation, independent of SQLite.
use crate::error::{ClmError, Result, StorageErrorCode};
use super::mcard_record::{verify_record, MCardRecord, RecordVerification};

pub fn require_verified(record: &MCardRecord) -> Result<String> {
    match verify_record(record) {
        RecordVerification::DeclaredOk { algorithm } => Ok(algorithm),
        verdict => Err(ClmError::storage(StorageErrorCode::CorruptedContent,
            format!("record failed declared content-address verification: {verdict:?}"))),
    }
}

/// Implementations reject unverified content before returning or committing it.
/// Qualified references must agree with the algorithm in the stored row's g_time.
pub trait RecordStorePort {
    fn read_record(&self, reference: &str) -> Result<Option<MCardRecord>>;
    fn read_text(&self, reference: &str) -> Result<Option<String>>;
    fn insert_record(&self, record: &MCardRecord) -> Result<bool>;
    fn store_named_content(&self, handle: &str, content: &[u8]) -> std::result::Result<MCardRecord, String>;
}