oxzy_lib/
lib.rs

1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4// ##### init #####
5
6/// Directories a plugin is supposed to use for configuration and data caching.
7#[derive(Debug, Serialize, Deserialize)]
8pub struct PluginInitDirs {
9    /// Path to a directory where the plugin will find its config.
10    /// This typically includes a `config.json` and further required files.
11    ///
12    /// This directory can be read-only.
13    pub config: PathBuf,
14
15    /// Path to a directory where the plugin is allowed to write data for caching.
16    ///
17    /// This directory needs to be read-and-write.
18    pub cache: PathBuf,
19}
20
21/// Metadata returned by a plugin after initialization.
22#[derive(Debug, Serialize, Deserialize)]
23pub struct PluginMetadata {
24    /// Name of the plugin
25    pub name: String,
26
27    /// Description of the plugin
28    pub description: String,
29
30    /// Version of the plugin
31    pub version: String,
32}
33
34// ##### query #####
35
36/// A singular query result, a list of these is returned by calling the query function on a plugin.
37#[derive(Debug, Serialize, Deserialize)]
38pub struct QueryResult {
39    /// Title of the result.
40    pub title: String,
41
42    /// Optional description of the result.
43    pub description: Option<String>,
44}
45
46// ##### handle #####
47
48/// Entry send to a plugins handle function, containing the selected entry and args.
49#[derive(Debug, Serialize, Deserialize)]
50pub struct HandleEntry {
51    /// Query selected by the user
52    pub entry: QueryResult,
53
54    /// Optional args passed by the user
55    pub args: Vec<String>,
56}
57
58/// Result of a plugins handle function, tells the launcher whether it should exit or continue running.
59#[derive(Debug, Serialize, Deserialize)]
60pub enum HandleResult {
61    /// Keep launcher active after calling the handle function
62    Continue,
63
64    /// Close the launcher after the call to the handle function
65    Exit,
66}