Skip to main content

CapabilityEnv

Struct CapabilityEnv 

Source
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: PathBuf

The app directory.

§app_id: String

The 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: Table

The whole lumen.toml, parsed but untyped. A capability reads its own section with Self::section; nothing here knows which sections exist.

§headless: bool

No 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

Source

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.

Source

pub fn headless(self, headless: bool) -> Self

Builder: mark the run as headless. See Self::headless.

Source

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.

Source

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.

Source

pub fn provided<T: Any + Send + Sync>(&self) -> Option<&T>

What Self::provide was handed under T, when anything was.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoResult<T> for T

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ConditionalSend for T
where T: Send,