pub struct AliasStore { /* private fields */ }Expand description
Persistent alias storage backed by a JSON file.
Aliases are stored at ~/.local/share/rec/aliases.json (the parent
of the sessions data directory). All writes use atomic tmp-rename
to prevent corruption.
Implementations§
Source§impl AliasStore
impl AliasStore
Sourcepub fn new(paths: &Paths) -> Self
pub fn new(paths: &Paths) -> Self
Create a new AliasStore using the given paths.
The alias file is placed in the parent of data_dir (which points
to ~/.local/share/rec/sessions/), giving ~/.local/share/rec/aliases.json.
Sourcepub fn get(&self, alias: &str) -> Result<Option<String>>
pub fn get(&self, alias: &str) -> Result<Option<String>>
Look up an alias by name.
Returns Ok(None) if the alias doesn’t exist or the file hasn’t
been created yet.
§Errors
Returns an error if the alias file exists but cannot be read or parsed.
Sourcepub fn set(&self, alias: &str, session: &str) -> Result<()>
pub fn set(&self, alias: &str, session: &str) -> Result<()>
Set an alias to point to a session name.
Overwrites any existing alias with the same name.
§Errors
Returns an error if the alias file cannot be read or written.
Auto Trait Implementations§
impl Freeze for AliasStore
impl RefUnwindSafe for AliasStore
impl Send for AliasStore
impl Sync for AliasStore
impl Unpin for AliasStore
impl UnwindSafe for AliasStore
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
Mutably borrows from an owned value. Read more