Skip to content

Commit 47852e5

Browse files
oknozormmstick
authored andcommitted
feat: add a toolkit crate for both client and pop-launcher-bin
1 parent a5c2569 commit 47852e5

File tree

12 files changed

+56
-24
lines changed

12 files changed

+56
-24
lines changed

Cargo.lock

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repository = "https://github.com/pop-os/launcher"
88
edition = "2018"
99

1010
[workspace]
11-
members = ["bin", "plugins", "service"]
11+
members = ["bin", "plugins", "service", "toolkit"]
1212

1313
[dependencies]
1414
const_format = "0.2.22"

bin/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ publish = false
88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
99

1010
[dependencies]
11-
pop-launcher-plugins = { path = "../plugins" }
12-
pop-launcher-service = { path = "../service" }
11+
pop-launcher-toolkit = { path = "../toolkit" }
1312
tracing = "0.1.32"
1413
tracing-subscriber = { version = "0.3.9", default-features = false, features = ["std", "fmt", "env-filter"] }
1514
dirs = "4.0.0"

bin/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2021 System76 <[email protected]>
22
// SPDX-License-Identifier: MPL-2.0
33

4-
use pop_launcher_plugins as plugins;
5-
use pop_launcher_service as service;
4+
use pop_launcher_toolkit::plugins;
5+
use pop_launcher_toolkit::service;
66

77
use mimalloc::MiMalloc;
88

plugins/src/web/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::Deserialize;
55
use slab::Slab;
66
use std::collections::HashMap;
77

8-
#[derive(Default)]
8+
#[derive(Default, Clone)]
99
pub struct Config {
1010
matches: HashMap<String, u32>,
1111
queries: Slab<Vec<Definition>>,
@@ -29,18 +29,18 @@ impl Config {
2929
}
3030
}
3131

32-
#[derive(Debug, Deserialize)]
32+
#[derive(Debug, Deserialize, Clone)]
3333
pub struct RawConfig {
3434
pub rules: Vec<Rule>,
3535
}
3636

37-
#[derive(Debug, Deserialize)]
37+
#[derive(Debug, Deserialize, Clone)]
3838
pub struct Rule {
3939
pub matches: Vec<String>,
4040
pub queries: Vec<Definition>,
4141
}
4242

43-
#[derive(Debug, Deserialize)]
43+
#[derive(Debug, Deserialize, Clone)]
4444
pub struct Definition {
4545
pub name: String,
4646
pub query: String,

plugins/src/web/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ use url::Url;
1212

1313
use pop_launcher::*;
1414

15-
use self::config::{Config, Definition};
15+
pub use config::{Config, Definition, load};
1616
use regex::Regex;
1717

1818
mod config;
19-
2019
pub async fn main() {
2120
let mut app = App::default();
2221

service/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ mod client;
55
mod plugins;
66

77
pub use client::*;
8+
pub use plugins::config;
9+
pub use plugins::external::load;
810

911
use crate::plugins::*;
1012
use flume::{Receiver, Sender};

service/src/plugins/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
path::{Path, PathBuf},
99
};
1010

11-
#[derive(Debug, Default, Deserialize)]
11+
#[derive(Debug, Default, Deserialize, Clone)]
1212
pub struct PluginConfig {
1313
pub name: Cow<'static, str>,
1414
pub description: Cow<'static, str>,
@@ -32,7 +32,7 @@ pub struct PluginConfig {
3232
pub history: bool,
3333
}
3434

35-
#[derive(Debug, Default, Deserialize)]
35+
#[derive(Debug, Default, Deserialize, Clone)]
3636
pub struct PluginBinary {
3737
path: Cow<'static, str>,
3838

@@ -41,7 +41,7 @@ pub struct PluginBinary {
4141
args: Vec<Cow<'static, str>>,
4242
}
4343

44-
#[derive(Debug, Default, Deserialize)]
44+
#[derive(Debug, Default, Deserialize, Clone)]
4545
pub struct PluginQuery {
4646
#[serde(
4747
default,

service/src/plugins/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Copyright 2021 System76 <[email protected]>
22
// SPDX-License-Identifier: MPL-2.0
33

4-
mod config;
54
pub(crate) mod external;
5+
pub mod config;
66
pub mod help;
77

8+
pub use external::load;
9+
810
pub use self::config::{PluginBinary, PluginConfig, PluginPriority, PluginQuery};
911
pub use self::external::ExternalPlugin;
1012
pub use self::help::HelpPlugin;

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ pub type Generation = u32;
4444
/// u32 value defining the indice of a slot.
4545
pub type Indice = u32;
4646

47-
#[derive(Debug, Deserialize, Serialize)]
47+
#[derive(Debug, Deserialize, Serialize, Clone)]
4848
pub struct ContextOption {
4949
pub id: Indice,
5050
pub name: String,
5151
}
5252

53-
#[derive(Debug, Deserialize, Serialize)]
53+
#[derive(Debug, Deserialize, Serialize, Clone)]
5454
pub enum GpuPreference {
5555
Default,
5656
NonDefault,
@@ -65,7 +65,7 @@ pub enum IconSource {
6565
}
6666

6767
/// Sent from a plugin to the launcher service.
68-
#[derive(Debug, Deserialize, Serialize)]
68+
#[derive(Debug, Deserialize, Serialize, Clone)]
6969
pub enum PluginResponse {
7070
/// Append a new search item to the launcher.
7171
Append(PluginSearchResult),
@@ -92,7 +92,7 @@ pub enum PluginResponse {
9292
}
9393

9494
/// Search information from a plugin to be sorted and filtered by the launcher service.
95-
#[derive(Debug, Default, Deserialize, Serialize)]
95+
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
9696
pub struct PluginSearchResult {
9797
/// Numeric identifier tracked by the plugin.
9898
pub id: Indice,
@@ -111,7 +111,7 @@ pub struct PluginSearchResult {
111111
}
112112

113113
// Sent to the input pipe of the launcher service, and disseminated to its plugins.
114-
#[derive(Debug, Deserialize, Serialize)]
114+
#[derive(Debug, Deserialize, Serialize, Clone)]
115115
pub enum Request {
116116
/// Activate on the selected item.
117117
Activate(Indice),
@@ -132,7 +132,7 @@ pub enum Request {
132132
}
133133

134134
/// Sent from the launcher service to a frontend.
135-
#[derive(Debug, Deserialize, Serialize)]
135+
#[derive(Debug, Deserialize, Serialize, Clone)]
136136
pub enum Response {
137137
// An operation was performed and the frontend may choose to exit its process.
138138
Close,
@@ -153,7 +153,7 @@ pub enum Response {
153153
}
154154

155155
/// Serialized response to launcher frontend about a search result.
156-
#[derive(Debug, Serialize, Deserialize)]
156+
#[derive(Debug, Serialize, Deserialize, Clone)]
157157
pub struct SearchResult {
158158
/// Numeric identifier tracked by the plugin.
159159
pub id: Indice,

0 commit comments

Comments
 (0)