pub struct CapabilityEnv {
pub app_dir: PathBuf,
pub app_id: String,
pub declared_app_id: Option<String>,
pub config: Table,
pub headless: bool,
/* private fields */
}Expand description
What a capability is installed with: the app’s location, identity, and configuration, the run mode, and a bounded view of its sources.
Fields§
§app_dir: PathBufThe app directory.
app_id: StringThe app’s identity: [app] id, or the one derived from the
directory name when the file leaves it unset.
declared_app_id: Option<String>[app] id exactly as declared, None when the file leaves it unset.
A subsystem whose platform keys state off an id the author chose
(notification attribution, for one) reads this rather than the
derived form.
config: TableThe whole lumen.toml, parsed but untyped. A capability reads its own
section with Self::section; nothing here knows which sections
exist.
headless: boolNo interactive session: a headless or bounded run, an automation driver, a test. A subsystem that exists for a person at a window stays idle.
Implementations§
Source§impl CapabilityEnv
impl CapabilityEnv
Sourcepub fn new(
app_dir: impl Into<PathBuf>,
config: Table,
sources: String,
opaque: bool,
) -> Self
pub fn new( app_dir: impl Into<PathBuf>, config: Table, sources: String, opaque: bool, ) -> Self
An environment for the app at app_dir.
sources is a bounded concatenation of the app’s markup, script and
style files, which Self::sources_mention scans. opaque says
that scan cannot see everything the app may do (a precompiled artifact
with no readable source, an embedder’s Rust hooks), in which case
every mention query answers yes.
Sourcepub fn headless(self, headless: bool) -> Self
pub fn headless(self, headless: bool) -> Self
Builder: mark the run as headless. See Self::headless.
Sourcepub fn opaque(self) -> Self
pub fn opaque(self) -> Self
Builder: declare the sources opaque, so every Self::sources_mention
query answers yes. For a run the scan cannot see all of: an embedder’s
Rust hooks may drive any subsystem.
Sourcepub fn provide<T: Any + Send + Sync>(&mut self, value: T)
pub fn provide<T: Any + Send + Sync>(&mut self, value: T)
Hand a subsystem something the run has and this crate does not name: the markup front end a run from source was given, for one. Keyed by type; a second value of the same type replaces the first.
Sourcepub fn provided<T: Any + Send + Sync>(&self) -> Option<&T>
pub fn provided<T: Any + Send + Sync>(&self) -> Option<&T>
What Self::provide was handed under T, when anything was.
Sourcepub fn sources_mention(&self, needles: &[&str]) -> bool
pub fn sources_mention(&self, needles: &[&str]) -> bool
Whether the app’s sources contain any of needles.
Errs toward yes: when the sources cannot be read in full, every
query answers true, so a subsystem gated on this is installed
whenever it might be used and skipped only when it provably is not.
Sourcepub fn section<T: DeserializeOwned + Default>(&self, name: &str) -> T
pub fn section<T: DeserializeOwned + Default>(&self, name: &str) -> T
The [name] table of lumen.toml, read into T.
A missing table is T::default(). A table that does not fit T is
reported and also read as the default, so one bad key disables the
section rather than the app.