Skip to main content

day_spec/
applications.rs

1// Copyright © The Daybrite Project
2// SPDX-License-Identifier: MPL-2.0
3
4//! System application associations. Identifiers are opaque, platform-owned values.
5
6#[derive(Clone, Debug, PartialEq, Eq)]
7pub struct Application {
8    /// Persist this identifier to reopen with a chosen app. It may become stale after removal.
9    pub id: String,
10    /// Localized application name supplied by the OS, not an app translation key.
11    pub name: String,
12}
13
14#[derive(Clone, Debug, PartialEq, Eq)]
15pub enum HandlerQuery {
16    /// Absolute URL, including file URLs for existing documents.
17    Url(String),
18    /// Scheme without a colon, for example `https` or `mailto`.
19    Scheme(String),
20    MimeType(String),
21    /// Extension without a leading dot, for example `pdf`.
22    Extension(String),
23}
24
25#[derive(Clone, Debug, Default, PartialEq, Eq)]
26pub struct ApplicationHandlers {
27    pub default: Option<Application>,
28    /// Deduplicated applications, including the default if one exists.
29    pub applications: Vec<Application>,
30}
31
32#[derive(Clone, Copy, Debug, PartialEq, Eq)]
33pub enum ApplicationError {
34    Unsupported,
35    InvalidInput,
36    NotFound,
37    LaunchFailed,
38}
39
40/// May run on an OS completion queue; deliver to the UI executor before touching app state.
41pub type OpenApplicationCompletion = Box<dyn FnOnce(Result<(), ApplicationError>) + Send>;