sim-lib-compute-wgpu 0.1.0

Evidence-based wgpu tensor compute site discovery for SIM.
Documentation
//! Stable host materialization cache for resident wgpu tensors.

use std::sync::{Arc, OnceLock};

/// Caches exactly one synchronized host materialization result.
#[derive(Debug, Default)]
pub struct WgpuMaterializationCache {
    cells: OnceLock<Result<Arc<[u8]>, String>>,
}

impl WgpuMaterializationCache {
    /// Returns the cached materialization or records the first result.
    pub fn get_or_try_init(
        &self,
        materialize: impl FnOnce() -> Result<Arc<[u8]>, String>,
    ) -> Result<Arc<[u8]>, String> {
        self.cells.get_or_init(materialize).clone()
    }
}