More queryer work

This commit is contained in:
Michael Zhang 2023-04-25 08:16:38 -05:00
parent 733ab6f964
commit 7089d2064f
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
5 changed files with 112 additions and 5 deletions

65
Cargo.lock generated
View file

@ -602,6 +602,26 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "dirs"
version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dece029acd3353e3a58ac2e3eb3c8d6c35827a892edc6cc4138ef9c33df46ecd"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04414300db88f70d74c5ff54e50f9e1d1737d9a5b90f53fcf2e95ca2a9ab554b"
dependencies = [
"libc",
"redox_users",
"windows-sys 0.45.0",
]
[[package]]
name = "dispatch"
version = "0.2.0"
@ -740,7 +760,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59a98bbaacea1c0eb6a0876280051b892eb73594fd90cf3b20e9c817029c57d2"
dependencies = [
"toml",
"toml 0.5.11",
]
[[package]]
@ -1911,8 +1931,11 @@ version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"dirs",
"iced",
"once_cell",
"serde",
"toml 0.7.3",
"tracing",
"tracing-subscriber",
"winit 0.28.3",
@ -2028,6 +2051,17 @@ dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
"redox_syscall 0.2.16",
"thiserror",
]
[[package]]
name = "renderdoc-sys"
version = "0.7.1"
@ -2105,6 +2139,9 @@ name = "serde"
version = "1.0.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
@ -2117,6 +2154,15 @@ dependencies = [
"syn 2.0.14",
]
[[package]]
name = "serde_spanned"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4"
dependencies = [
"serde",
]
[[package]]
name = "servo-fontconfig"
version = "0.5.1"
@ -2372,11 +2418,26 @@ dependencies = [
"serde",
]
[[package]]
name = "toml"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
@ -2385,6 +2446,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
]

View file

@ -6,8 +6,11 @@ edition = "2021"
[dependencies]
anyhow = "1.0.70"
clap = { version = "4.2.1", features = ["derive"] }
dirs = "5.0.0"
iced = "0.8.0"
once_cell = "1.17.1"
serde = { version = "1.0.160", features = ["derive"] }
toml = "0.7.3"
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
winit = "0.28.3"

7
queryer/src/config.rs Normal file
View file

@ -0,0 +1,7 @@
use std::path::PathBuf;
#[derive(Debug, Deserialize)]
pub struct Config {
/// The path to the "Searcher" executable
pub searcher_path: PathBuf,
}

View file

@ -1,20 +1,37 @@
#[macro_use]
extern crate serde;
mod config;
mod searcher;
use anyhow::Result;
use clap::Parser;
use iced::keyboard::KeyCode;
use iced::widget::text_input;
use iced::{executor, keyboard, subscription, window, Event, Subscription};
use iced::{Application, Command, Element, Settings, Theme};
use once_cell::sync::Lazy;
#[derive(Debug, Parser)]
struct Opt {}
static SEARCH_INPUT_ID: Lazy<text_input::Id> =
Lazy::new(text_input::Id::unique);
pub fn main() -> iced::Result {
pub fn main() -> Result<()> {
let opt = Opt::parse();
// TODO: Open the config directory to parse the config
let mut settings = Settings::default();
settings.window.decorations = false;
settings.window.resizable = false;
settings.window.size = (640, 280);
App::run(settings)
App::run(settings)?;
Ok(())
}
#[derive(Default)]
@ -28,13 +45,13 @@ impl Application for App {
type Message = Message;
type Theme = Theme;
fn new(_flags: ()) -> (App, Command<Self::Message>) {
fn new(_: ()) -> (App, Command<Self::Message>) {
let focus_command = text_input::focus(SEARCH_INPUT_ID.clone());
(App::default(), focus_command)
}
fn title(&self) -> String {
String::from("A cool application")
String::from("Queryer")
}
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {

17
queryer/src/searcher.rs Normal file
View file

@ -0,0 +1,17 @@
use anyhow::Result;
pub struct SearchResult {}
pub trait Searcher {
fn query(&self, query: impl AsRef<str>) -> Result<Vec<SearchResult>>;
}
pub struct TrivialSearcher {}
impl Searcher for TrivialSearcher {
fn query(&self, query: impl AsRef<str>) -> Result<Vec<SearchResult>> {
let query = query.as_ref();
todo!()
}
}