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
impl Repository
sourcepub async fn new(
path: impl AsRef<Path>,
is_bare: bool
) -> Result<Self, WsvcFsError>
pub async fn new( path: impl AsRef<Path>, is_bare: bool ) -> Result<Self, WsvcFsError>
init a new repository at path.
sourcepub async fn open(
path: impl AsRef<Path>,
is_bare: bool
) -> Result<Self, WsvcFsError>
pub async fn open( path: impl AsRef<Path>, is_bare: bool ) -> Result<Self, WsvcFsError>
open a repository at path.
sourcepub async fn lock(&self) -> Result<(), WsvcFsError>
pub async fn lock(&self) -> Result<(), WsvcFsError>
lock repository for write.
notice that the Repository struct is Clone
able, 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.
sourcepub async fn check_lock(&self) -> Result<(), WsvcFsError>
pub async fn check_lock(&self) -> Result<(), WsvcFsError>
check if the repository is locked.
sourcepub fn unlock(&self) -> Result<(), WsvcFsError>
pub fn unlock(&self) -> Result<(), WsvcFsError>
unlock repository.
sourcepub async fn try_open(path: impl AsRef<Path>) -> Result<Self, WsvcFsError>
pub async fn try_open(path: impl AsRef<Path>) -> Result<Self, WsvcFsError>
try open a repository at path.
the bare
option will be guessed.
sourcepub async fn temp_dir(&self) -> Result<PathBuf, WsvcFsError>
pub async fn temp_dir(&self) -> Result<PathBuf, WsvcFsError>
get the temp folder of the repository.
sourcepub async fn objects_dir(&self) -> Result<PathBuf, WsvcFsError>
pub async fn objects_dir(&self) -> Result<PathBuf, WsvcFsError>
get the objects folder of the repository.
sourcepub async fn trees_dir(&self) -> Result<PathBuf, WsvcFsError>
pub async fn trees_dir(&self) -> Result<PathBuf, WsvcFsError>
get the trees folder of the repository.
sourcepub async fn records_dir(&self) -> Result<PathBuf, WsvcFsError>
pub async fn records_dir(&self) -> Result<PathBuf, WsvcFsError>
get the records folder of the repository.
sourcepub async fn store_blob(
&self,
workspace: impl AsRef<Path>,
rel_path: impl AsRef<Path>
) -> Result<Blob, WsvcFsError>
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.
sourcepub async fn checkout_blob(
&self,
blob_hash: &ObjectId,
workspace: impl AsRef<Path>,
rel_path: impl AsRef<Path>
) -> Result<(), WsvcFsError>
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.
sourcepub async fn read_blob(
&self,
blob_hash: &ObjectId
) -> Result<Vec<u8>, WsvcFsError>
pub async fn read_blob( &self, blob_hash: &ObjectId ) -> Result<Vec<u8>, WsvcFsError>
read blob data from objects database.
sourcepub async fn write_tree_recursively(
&self,
workspace: impl AsRef<Path> + Clone
) -> Result<(Tree, bool), WsvcFsError>
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.
sourcepub async fn read_tree(&self, tree_hash: &ObjectId) -> Result<Tree, WsvcFsError>
pub async fn read_tree(&self, tree_hash: &ObjectId) -> Result<Tree, WsvcFsError>
read a tree object from trees dir
sourcepub 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,
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.
sourcepub async fn store_record(&self, record: &Record) -> Result<(), WsvcFsError>
pub async fn store_record(&self, record: &Record) -> Result<(), WsvcFsError>
store a record to records dir.
sourcepub async fn find_record_for_tree(
&self,
tree_id: &Hash
) -> Result<Option<Record>, WsvcFsError>
pub async fn find_record_for_tree( &self, tree_id: &Hash ) -> Result<Option<Record>, WsvcFsError>
find a record for the specified tree.
sourcepub async fn commit_record(
&self,
workspace: &Path,
author: impl AsRef<str>,
message: impl AsRef<str>
) -> Result<Record, WsvcFsError>
pub async fn commit_record( &self, workspace: &Path, author: impl AsRef<str>, message: impl AsRef<str> ) -> Result<Record, WsvcFsError>
commit a record.
sourcepub async fn read_record(
&self,
record_hash: &ObjectId
) -> Result<Record, WsvcFsError>
pub async fn read_record( &self, record_hash: &ObjectId ) -> Result<Record, WsvcFsError>
read a record from records dir.
sourcepub async fn checkout_record(
&self,
record_hash: &ObjectId,
workspace: &Path
) -> Result<Record, WsvcFsError>
pub async fn checkout_record( &self, record_hash: &ObjectId, workspace: &Path ) -> Result<Record, WsvcFsError>
checkout a record to workspace.
sourcepub async fn get_records(&self) -> Result<Vec<Record>, WsvcFsError>
pub async fn get_records(&self) -> Result<Vec<Record>, WsvcFsError>
get all records
sourcepub async fn get_trees_of_record(
&self,
record_hash: &ObjectId
) -> Result<Vec<Tree>, WsvcFsError>
pub async fn get_trees_of_record( &self, record_hash: &ObjectId ) -> Result<Vec<Tree>, WsvcFsError>
get all trees of a record
sourcepub async fn get_latest_record(&self) -> Result<Option<Record>, WsvcFsError>
pub async fn get_latest_record(&self) -> Result<Option<Record>, WsvcFsError>
get the latest record
sourcepub async fn get_head_record(&self) -> Result<Option<Record>, WsvcFsError>
pub async fn get_head_record(&self) -> Result<Option<Record>, WsvcFsError>
get the head record
pub async fn write_origin(&self, url: String) -> Result<(), WsvcFsError>
pub async fn read_origin(&self) -> Result<String, WsvcFsError>
Trait Implementations§
source§impl Clone for Repository
impl Clone for Repository
source§fn clone(&self) -> Repository
fn clone(&self) -> Repository
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more