Skip to main content

surfaces

Function surfaces 

Source
pub fn surfaces(registry: &CapabilityRegistry, o: &Object) -> Vec<Surface>
Expand description

Every surface that answers for one object, derived from the registry’s exposures rather than listed here.

The MCP line is the object’s own resource exposure; the HTTP and command-line lines are the exposures of the capability that reads an object by URI, whichever capability that is and whatever route it is mounted at, so a route that moves moves here too.

use majordomus_cli::capability::builtin;
use majordomus_cli::capability::registry::CapabilityRegistry;
use majordomus_cli::entity::surfaces;

let registry = CapabilityRegistry::builder()
    .with_builtin(builtin::all())
    .build()
    .unwrap();

let found = surfaces(&registry, &object("rule", "project.x@1"));
// the Cockpit always answers, because an address is derived and never registered
assert!(found.iter().any(|s| s.surface == "cockpit"
    && s.address == "/cockpit/objects/rule/project-x-1"));
// and nothing here is written down: every line came out of the registry's exposures
assert!(found.iter().all(|s| !s.address.is_empty()));