Skip to main content

snip_it/
lib.rs

1//! Library for the `snp` snippet manager.
2//!
3//! Most of the implementation lives in submodules that are also used by
4//! the `snp` binary entry point in `src/main.rs`. The library is also
5//! re-exported so that integration tests under `tests/` can exercise the
6//! public API (notably `sync::SyncClient` and the proto types) against a
7//! real `snip-sync` server.
8
9// Public modules form the stable API surface for crates.io consumers.
10// Anything marked `pub(crate)` is internal implementation and may change
11// without a semver bump.
12//
13// The `snp` binary lives in the same package as this library but is a
14// separate crate, so it can only see `pub` items here. The CLI uses
15// `commands`, `config`, `error`, `logging`, and `ui` directly. The
16// truly internal modules (`clipboard`, `library`, `sync_commands`,
17// `utils`) are accessed only via `crate::` from sibling modules, so
18// they can be hidden from external consumers.
19pub mod commands;
20pub mod config;
21pub mod encryption;
22pub mod error;
23pub mod logging;
24pub mod proto;
25pub mod sync;
26pub mod ui;
27
28pub(crate) mod clipboard;
29pub(crate) mod library;
30pub(crate) mod sync_commands;
31pub(crate) mod utils;
32
33pub use error::{SnipError, SnipResult};
34
35/// Aggregated data for all snippets passed to the TUI selector.
36///
37/// Contains parallel vectors of snippet metadata where index `i` corresponds
38/// to the same snippet across all fields.
39pub struct SnippetData {
40    pub descriptions: Vec<String>,
41    pub commands: Vec<String>,
42    pub tags: Vec<Vec<String>>,
43    pub folders: Vec<Vec<String>>,
44    pub favorites: Vec<bool>,
45}
46
47/// Result of processing a snippet selection from the TUI.
48pub enum ProcessResult {
49    /// User cancelled the selection.
50    Cancel,
51    /// No snippet was selected; continue to next prompt.
52    Continue,
53    /// A snippet command was selected; contains the expanded command string.
54    Done(String),
55}