Struct Repo

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

Structure properties.

Implementations§

Source§

impl Repo

Repo functions.

Source

pub fn init<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Creates a new --bare repository in the specified folder.

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Opens an existing repository.

Source

pub fn path(&self) -> &Path

Returns repository path.

Source

pub fn len(&self) -> usize

Returns the number of all keys.

Source

pub fn has_commits(&self) -> bool

Returns true if repository has no commits.

Source

pub fn has_branches(&self) -> bool

Returns true if at least one branch exists.

Source

pub fn has_keys(&self) -> bool

Returns true if at least one key exists.

Source

pub fn has_branch(&self, name: &str) -> bool

Returns true if the provided branch exists.

Source

pub fn has_key(&self, name: &str) -> bool

Returns true if the key exists.

Source

pub fn branches(&self) -> Vec<String>

Returns working branch name.

Source

pub fn keys(&self) -> Vec<String>

List all available keys.

Source

pub fn branch(&self) -> Option<String>

Returns working branch name.

Source

pub fn key(&self, name: &str) -> Option<Vec<u8>>

Retrieves key content.

Source

pub fn switch_branch(&mut self, name: &str) -> Result<(), Error>

Ensures new working branch. There must be at least one commit in the repository for this method to work other wise the error is thrown.

Source

pub fn remove_branch(&mut self, name: &str) -> Result<(), Error>

Removes working branch. Note that the current branch can not be removed and you have to first switch to a new branch.

Source

pub fn insert_key(&mut self, name: &str, value: &[u8]) -> Result<(), Error>

Stages key for commit.

Source

pub fn reset_key(&mut self, name: &str) -> Result<(), Error>

Stages key for removal.

Source

pub fn remove_key(&mut self, name: &str) -> Result<(), Error>

Stages key for removal.

Source

pub fn changed(&self) -> bool

Returns true if any key has been changed.

Source

pub fn key_changed(&self, name: &str) -> bool

Returns true if the key content has been changed.

Source

pub fn reset(&mut self) -> Result<(), Error>

Reset all keys.

Source

pub fn remove(&mut self) -> Result<(), Error>

Remove all keys.

Source

pub fn commit(&self, message: &str) -> Result<(), Error>

Commit data.

Auto Trait Implementations§

§

impl Freeze for Repo

§

impl RefUnwindSafe for Repo

§

impl Send for Repo

§

impl !Sync for Repo

§

impl Unpin for Repo

§

impl UnwindSafe for Repo

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,