Struct wsvc::model::Repository

source ·
pub struct Repository {
    pub path: PathBuf,
    pub lock: String,
}
Expand description

Repository stand for a repo.

Fields§

§path: PathBuf§lock: String

Implementations§

source§

impl Repository

source

pub async fn new( path: impl AsRef<Path>, is_bare: bool ) -> Result<Self, WsvcFsError>

init a new repository at path.

source

pub async fn open( path: impl AsRef<Path>, is_bare: bool ) -> Result<Self, WsvcFsError>

open a repository at path.

source

pub async fn lock(&self) -> Result<(), WsvcFsError>

lock repository for write.

notice that the Repository struct is Cloneable, so there is still risky when you cloned multiple Repository struct in different threads. it is recommended to construct Repository everytime when you need it, the lock function is just for convenience.

source

pub async fn check_lock(&self) -> Result<(), WsvcFsError>

check if the repository is locked.

source

pub fn unlock(&self) -> Result<(), WsvcFsError>

unlock repository.

source

pub async fn try_open(path: impl AsRef<Path>) -> Result<Self, WsvcFsError>

try open a repository at path.

the bare option will be guessed.

source

pub async fn temp_dir(&self) -> Result<PathBuf, WsvcFsError>

get the temp folder of the repository.

source

pub async fn objects_dir(&self) -> Result<PathBuf, WsvcFsError>

get the objects folder of the repository.

source

pub async fn trees_dir(&self) -> Result<PathBuf, WsvcFsError>

get the trees folder of the repository.

source

pub async fn records_dir(&self) -> Result<PathBuf, WsvcFsError>

get the records folder of the repository.

source

pub async fn store_blob( &self, workspace: impl AsRef<Path>, rel_path: impl AsRef<Path> ) -> Result<Blob, WsvcFsError>

store a blob file from workspace to objects dir.

source

pub async fn checkout_blob( &self, blob_hash: &ObjectId, workspace: impl AsRef<Path>, rel_path: impl AsRef<Path> ) -> Result<(), WsvcFsError>

checkout a blob file from objects dir to workspace.

source

pub async fn read_blob( &self, blob_hash: &ObjectId ) -> Result<Vec<u8>, WsvcFsError>

read blob data from objects database.

source

pub async fn write_tree_recursively( &self, workspace: impl AsRef<Path> + Clone ) -> Result<(Tree, bool), WsvcFsError>

write all trees of current workspace to trees dir.

source

pub async fn read_tree(&self, tree_hash: &ObjectId) -> Result<Tree, WsvcFsError>

read a tree object from trees dir

source

pub fn checkout_tree<'life0, 'life1, 'life_self, 'async_recursion>( &'life_self self, tree: &'life0 Tree, workspace: &'life1 Path ) -> Pin<Box<dyn Future<Output = Result<(), WsvcFsError>> + 'async_recursion>>where 'life0: 'async_recursion, 'life1: 'async_recursion, 'life_self: 'async_recursion,

checkout a tree to workspace.

source

pub async fn store_record(&self, record: &Record) -> Result<(), WsvcFsError>

store a record to records dir.

source

pub async fn find_record_for_tree( &self, tree_id: &Hash ) -> Result<Option<Record>, WsvcFsError>

find a record for the specified tree.

source

pub async fn commit_record( &self, workspace: &Path, author: impl AsRef<str>, message: impl AsRef<str> ) -> Result<Record, WsvcFsError>

commit a record.

source

pub async fn read_record( &self, record_hash: &ObjectId ) -> Result<Record, WsvcFsError>

read a record from records dir.

source

pub async fn checkout_record( &self, record_hash: &ObjectId, workspace: &Path ) -> Result<Record, WsvcFsError>

checkout a record to workspace.

source

pub async fn get_records(&self) -> Result<Vec<Record>, WsvcFsError>

get all records

source

pub async fn get_trees_of_record( &self, record_hash: &ObjectId ) -> Result<Vec<Tree>, WsvcFsError>

get all trees of a record

source

pub async fn get_latest_record(&self) -> Result<Option<Record>, WsvcFsError>

get the latest record

source

pub async fn get_head_record(&self) -> Result<Option<Record>, WsvcFsError>

get the head record

source

pub async fn write_origin(&self, url: String) -> Result<(), WsvcFsError>

source

pub async fn read_origin(&self) -> Result<String, WsvcFsError>

Trait Implementations§

source§

impl Clone for Repository

source§

fn clone(&self) -> Repository

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Repository

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Repository

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Repository

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<T> FromRef<T> for Twhere T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,