pub struct SnippetStore {
pub snippets: Vec<Snippet>,
pub path_override: Option<PathBuf>,
pub targets: HashMap<String, Vec<String>>,
}Expand description
Snippet storage backed by ~/.purple/snippets (INI-style).
Fields§
§snippets: Vec<Snippet>§path_override: Option<PathBuf>Override path for save(). None uses the default ~/.purple/snippets.
targets: HashMap<String, Vec<String>>Default target host aliases per snippet name, persisted as the optional
hosts= line. Pre-selected when the run picker opens. Kept out of the
Snippet struct so existing call sites that build snippets stay
untouched; the association is by name.
Implementations§
Source§impl SnippetStore
impl SnippetStore
Sourcepub fn load(paths: Option<&Paths>) -> Self
pub fn load(paths: Option<&Paths>) -> Self
Load snippets from ~/.purple/snippets, resolved from the injected
paths. The resolved path is stored as path_override so a later
save() writes back to the same location without re-resolving.
Returns an empty store when the file does not exist (normal
first-use) or when no home directory is known.
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Save snippets to ~/.purple/snippets (atomic write, chmod 600).
Sourcepub fn targets_for(&self, name: &str) -> &[String]
pub fn targets_for(&self, name: &str) -> &[String]
Default target host aliases saved for name (empty when none).
Sourcepub fn set_targets(&mut self, name: &str, aliases: Vec<String>)
pub fn set_targets(&mut self, name: &str, aliases: Vec<String>)
Set (or clear, when empty) the default target host aliases for name.
Trait Implementations§
Source§impl Clone for SnippetStore
impl Clone for SnippetStore
Source§fn clone(&self) -> SnippetStore
fn clone(&self) -> SnippetStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SnippetStore
impl Debug for SnippetStore
Source§impl Default for SnippetStore
impl Default for SnippetStore
Source§fn default() -> SnippetStore
fn default() -> SnippetStore
Auto Trait Implementations§
impl Freeze for SnippetStore
impl RefUnwindSafe for SnippetStore
impl Send for SnippetStore
impl Sync for SnippetStore
impl Unpin for SnippetStore
impl UnsafeUnpin for SnippetStore
impl UnwindSafe for SnippetStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more