Skip to main content

BondManager

Struct BondManager 

Source
pub struct BondManager { /* private fields */ }
Expand description

SQLite-backed manager for Bonds.

Implementations§

Source§

impl BondManager

Source

pub fn new(db_path: Option<PathBuf>) -> Result<Self, BondError>

Open (or create) the DB at db_path. If None, defaults to $HOME/.bonds/bonds.db.

Source

pub fn list_bonds(&self) -> Result<Vec<Bond>, BondError>

List all bonds (most-recent first).

Source

pub fn get_bond(&self, identifier: &str) -> Result<Bond, BondError>

Get a single bond by ID or name. ID can be a unique prefix.

Source

pub fn create_bond<P: AsRef<Path>, Q: AsRef<Path>>( &self, source: P, target: Q, name: Option<String>, ) -> Result<Bond, BondError>

Create a symlink bond and persist it.

Source

pub fn update_bond( &self, id: &str, new_source: Option<PathBuf>, new_target: Option<PathBuf>, new_name: Option<String>, ) -> Result<Bond, BondError>

Update a bond’s source and/or target. Replaces the symlink on disk and updates the DB record.

Source

pub fn delete_bond( &self, id: &str, remove_target: bool, ) -> Result<Bond, BondError>

Delete a bond by id. If remove_target is true, non-symlink targets are removed too.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.