pub struct LinksRegistry { /* private fields */ }Expand description
In-memory registry of all configured links, backed by links.toml.
Implementations§
Source§impl LinksRegistry
impl LinksRegistry
pub fn new() -> Self
Sourcepub fn load(path: &Path) -> Result<Self>
pub fn load(path: &Path) -> Result<Self>
Load from a TOML file. Returns an empty registry if the file does not exist.
Sourcepub fn add(&mut self, info: LinkInfo) -> Result<()>
pub fn add(&mut self, info: LinkInfo) -> Result<()>
Add a new link. Returns an error if:
- A link with the same id already exists.
- Another link already points at the same
local_dir(one-dir one-link).
Sourcepub fn remove(&mut self, id: &LinkId) -> Result<()>
pub fn remove(&mut self, id: &LinkId) -> Result<()>
Remove a link by its id. Returns an error if not found.
Sourcepub fn get_by_name(&self, name: &str) -> Option<&LinkInfo>
pub fn get_by_name(&self, name: &str) -> Option<&LinkInfo>
Look up a link by its human-readable name.
Sourcepub fn get_by_dir(&self, dir: &Path) -> Option<&LinkInfo>
pub fn get_by_dir(&self, dir: &Path) -> Option<&LinkInfo>
Look up a link by its local_dir.
Trait Implementations§
Source§impl Debug for LinksRegistry
impl Debug for LinksRegistry
Source§impl Default for LinksRegistry
impl Default for LinksRegistry
Source§fn default() -> LinksRegistry
fn default() -> LinksRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LinksRegistry
impl RefUnwindSafe for LinksRegistry
impl Send for LinksRegistry
impl Sync for LinksRegistry
impl Unpin for LinksRegistry
impl UnsafeUnpin for LinksRegistry
impl UnwindSafe for LinksRegistry
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