liminal-server 0.27.4

Standalone server for the liminal messaging bus
Documentation
//! ACCESS-013 R2: where the agent registry's bounds are written.

use super::ServerConfig;
use crate::agents::config::AgentsConfig;

impl ServerConfig {
    /// The registry's bounds from whichever place writes them: `[agents]` at
    /// the top level, else `[auth.lys.agents]`; `None` when neither does.
    #[must_use]
    pub fn agents_config(&self) -> Option<AgentsConfig> {
        self.agents.or_else(|| {
            self.auth
                .as_ref()
                .and_then(|auth| auth.lys.as_ref())
                .and_then(|lys| lys.agents)
        })
    }

    /// The place [`Self::agents_config`] answers from, as the started line
    /// and `liminal check` say it: `top`, `auth.lys` or `none`.
    #[must_use]
    pub fn agents_place(&self) -> &'static str {
        if self.agents.is_some() {
            "top"
        } else if self.agents_config().is_some() {
            "auth.lys"
        } else {
            "none"
        }
    }
}