subc-daemon 0.49.3

Embeddable subc daemon: bootstrap, module supervision, and opaque-byte splice routing.
Documentation
//! Admission, status and approved daemon configuration share one publication.
use super::*;

pub(crate) struct Published {
    pub(super) admission: admission::AdmissionCache,
    pub(crate) approved_daemon: ApprovedDaemonView,
    pub(super) projection: polled::Projection,
}

impl Published {
    pub(crate) fn registration_declaration(&self, module: &str) -> Option<String> {
        self.admission
            .registration_declarations()?
            .get(module)
            .cloned()
    }
    pub(crate) fn is_recovering(&self) -> bool {
        self.admission.is_recovering()
    }
}

impl std::ops::Deref for Published {
    type Target = admission::AdmissionCache;
    fn deref(&self) -> &Self::Target {
        &self.admission
    }
}

impl RuntimeOwner {
    pub(crate) fn polled_snapshot(&self) -> Result<std::sync::Arc<Published>> {
        #[cfg(test)]
        self.polled_capture_count
            .fetch_add(1, std::sync::atomic::Ordering::Relaxed);
        if self.inner.is_poisoned() {
            return Err(GateError::new(
                "config_unavailable",
                "configuration owner lock is poisoned",
            ));
        }
        let snapshot = self
            .published
            .read()
            .map(|value| value.clone())
            .map_err(|_| {
                GateError::new(
                    "config_unavailable",
                    "configuration publication is unavailable",
                )
            })?;
        #[cfg(test)]
        if let Some(hook) = self.polled_capture_hook.lock().unwrap().take() {
            hook();
        }
        Ok(snapshot)
    }
}