Skip to main content

App

Struct App 

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

Builder for a fude application.

Implementations§

Source§

impl App

Source

pub fn new(identifier: impl Into<String>) -> Self

Create a new app. identifier is a reverse-DNS string used to locate the config / data directory (e.g. "com.example.editor").

Source

pub fn title(self, title: impl Into<String>) -> Self

Source

pub fn assets(self, root: impl Into<PathBuf>) -> Self

Directory served as the root of asset://localhost/. Typically your Vite/webpack dist/ output.

Source

pub fn command<F>(self, name: impl Into<String>, handler: F) -> Self
where F: Fn(&Ctx, &Value) -> Result<Value, String> + Send + Sync + 'static,

Register a custom IPC command.

Source

pub fn with_fs_sandbox(self) -> Self

Register the built-in allow-list FS commands: allow_path, allow_dir, list_directory, read_file, read_file_binary, write_file, write_file_binary, ensure_dir.

The frontend must call allow_path / allow_dir after a native dialog selection — no file I/O is permitted until then.

Source

pub fn with_settings(self) -> Self

Register load_settings / save_settings — persist an arbitrary JSON object at <app_config_dir>/settings.json via crate::atomic_write.

load_settings() returns the parsed object, or {} if none saved. save_settings({ settings: {...} }) writes atomically. The payload must be a JSON object; arrays / scalars are rejected.

Source

pub fn with_shell_open(self) -> Self

Register shell_open — opens URLs (http/https/mailto) or allow-listed local file paths in the OS default application.

File-path targets require App::with_fs_sandbox and must already be in the allow-list (via a dialog or manual allow_path).

Source

pub fn with_dialogs(self) -> Self

Register native dialog commands: dialog_open, dialog_save, dialog_ask, dialog_message.

Source

pub fn with_pty(self, allowed_tools: &[&str]) -> Self

Register PTY commands for spawning CLI agents (e.g. claude, codex).

Registers: pty_spawn, pty_write, pty_resize, pty_kill and emits pty:data / pty:exit events.

allowed_tools is the only set of binaries that may ever be spawned; anything else is rejected. Requires App::with_fs_sandbox to have been called — the PTY cwd must live inside an allow-listed directory.

Source

pub fn with_acp( self, adapters: Vec<AcpAdapterConfig>, client_name: impl Into<String>, client_version: impl Into<String>, ) -> Self

Register ACP (Agent Client Protocol) commands.

Registers 11 acp_* commands. Requires App::with_fs_sandbox — the agent’s fs/read_text_file / fs/write_text_file calls are intercepted and reject anything outside the user’s allow-list.

Source

pub fn run(self) -> Result<(), Box<dyn Error>>

Block on the event loop. Returns only when the window is closed.

Auto Trait Implementations§

§

impl Freeze for App

§

impl !RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

§

impl !UnwindSafe for App

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.