diff --git a/src/app.rs b/src/app.rs index 2eef601..ac6e258 100644 --- a/src/app.rs +++ b/src/app.rs @@ -23,6 +23,7 @@ pub enum Page { ClipboardHistory, } +/// The types of arrow keys #[allow(dead_code)] #[derive(Debug, Clone)] pub enum ArrowKey { @@ -32,6 +33,7 @@ pub enum ArrowKey { Right, } +/// The ways the cursor can move when a key is pressed #[derive(Debug, Clone)] pub enum Move { Back, diff --git a/src/app/tile.rs b/src/app/tile.rs index cad8dbf..617dbb7 100644 --- a/src/app/tile.rs +++ b/src/app/tile.rs @@ -41,12 +41,14 @@ impl Drop for ExtSender { fn drop(&mut self) {} } +/// All the indexed apps that rustcast can search for #[derive(Clone, Debug)] struct AppIndex { by_name: BTreeMap, } impl AppIndex { + /// Search for an element in the index that starts with the provided prefix fn search_prefix<'a>(&'a self, prefix: &'a str) -> impl Iterator + 'a { self.by_name .range(prefix.to_string()..) // start at prefix @@ -54,6 +56,7 @@ impl AppIndex { .map(|(_, v)| v) } + /// Factory function for creating pub fn from_apps(options: Vec) -> Self { let mut bmap = BTreeMap::new(); for app in options { diff --git a/src/utils.rs b/src/utils.rs index ff46090..263ca11 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -177,6 +177,7 @@ pub(crate) fn get_installed_apps(dir: impl AsRef, store_icons: bool) -> Ve .collect() } +/// Open the settings file with the system default editor pub fn open_settings() { thread::spawn(move || { NSWorkspace::new().openURL(&NSURL::fileURLWithPath( @@ -188,6 +189,7 @@ pub fn open_settings() { }); } +/// Open a provided URL (Platform specific) pub fn open_url(url: &str) { let url = url.to_owned(); thread::spawn(move || { @@ -198,6 +200,7 @@ pub fn open_url(url: &str) { }); } +/// Check if the provided string is a valid url pub fn is_valid_url(s: &str) -> bool { s.ends_with(".com") || s.ends_with(".net")