Skip to main content

ApplicationBuilder

Struct ApplicationBuilder 

Source
pub struct ApplicationBuilder { /* private fields */ }
Expand description

Assembles an Application from ports and modules.

Clock and event bus have exactly one sensible default and are pre-filled. Storage, credentials and notifications must be chosen explicitly — or taken from ApplicationBuilder::in_memory for tests.

Implementations§

Source§

impl ApplicationBuilder

Source

pub fn new() -> Self

Source

pub fn in_memory() -> Self

A fully in-memory application: no files, no keychain, no notifications.

This is the configuration from ADR-0002 — it makes the whole application testable without starting a desktop session.

Source

pub fn clock(self, clock: Arc<dyn Clock>) -> Self

Source

pub fn event_bus(self, events: EventBus) -> Self

Share an existing bus, e.g. one the host layer already subscribed to.

Source

pub fn storage(self, storage: Arc<dyn Storage>) -> Self

Source

pub fn secret_store(self, secrets: Arc<dyn SecretStore>) -> Self

Source

pub fn notifications(self, notifications: Arc<dyn NotificationService>) -> Self

Source

pub fn opener(self, opener: Arc<dyn Opener>) -> Self

Grant the ability to open external URLs. Omitted means the product does not have the capability at all, not that it is disabled at runtime.

Source

pub fn confirmation(self, confirmation: Arc<dyn ConfirmationService>) -> Self

Override the human confirmation service. The default denies everything, so a product that grants MCP mutation must call this — the error message in the MCP tool response tells the product author why.

Source

pub fn tray(self, tray: Arc<dyn TrayService>) -> Self

Give the application a system tray. Products without a tray never call this and get None — modules that need one see it through the platform.

Source

pub fn http_client(self, http: Arc<dyn HttpClient>) -> Self

Give the application an HTTP client.

One client for the whole application: it owns the connection pool, and several would defeat keep-alive (ADR-0014).

Source

pub fn connector(self, connector: impl Connector) -> Self

Register a connector.

The set of external services a build can reach is fixed here, at compile time, and is therefore auditable (ADR-0006).

Source

pub fn workspace_fs(self, workspace_fs: Arc<dyn WorkspaceFs>) -> Self

Give the application a workspace filesystem adapter (B2).

Source

pub fn workspace_watcher( self, workspace_watcher: Arc<dyn WorkspaceWatcher>, ) -> Self

Give the application a workspace watcher adapter (B3).

Source

pub fn process_runner(self, process_runner: Arc<dyn ProcessRunner>) -> Self

Give the application a process runner adapter (B1).

Source

pub fn global_shortcuts( self, global_shortcuts: Arc<dyn GlobalShortcutService>, ) -> Self

Give the application a global shortcut service adapter (B5).

Source

pub fn module(self, module: impl ApplicationModule) -> Self

Source

pub fn build(self) -> Result<Application, BuildError>

Trait Implementations§

Source§

impl Debug for ApplicationBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ApplicationBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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