Trait amisgitpm::pm::PMOperations
source · pub trait PMOperationswhere
Self: Sized,{
type Dirs: Directories;
type Store: ProjectStore<Self::Project>;
type Project: ProjectIface;
type Error: Error + From<Error> + From<CommonPMErrors> + From<Error>;
Show 14 methods
fn new() -> Result<Self, Self::Error>;
fn map_store_error(
err: <Self::Store as ProjectStore<Self::Project>>::Error
) -> Self::Error;
fn map_dir_error(err: <Self::Dirs as Directories>::Error) -> Self::Error;
fn get_store(&self) -> &Self::Store;
fn get_mut_store(&mut self) -> &mut Self::Store;
fn get_dirs(&self) -> &Self::Dirs;
fn copy_directory<T: AsRef<Path>, Q: AsRef<Path>>(
&self,
from: T,
to: Q
) -> Result<(), Self::Error>;
fn script_runner<T: AsRef<str>, Q: AsRef<[T]>>(
&self,
dir: &str,
script: Q
) -> Result<(), Self::Error>;
fn download(
&self,
prj: &Self::Project
) -> Result<(Repository, PathBuf), Self::Error> { ... }
fn switch_branch(
&self,
prj: &Self::Project,
repo: &Repository
) -> Result<(), Self::Error> { ... }
fn mv(&self, prj: &Self::Project, path: &Path) -> Result<(), Self::Error> { ... }
fn build(&self, prj: &Self::Project) -> Result<(), Self::Error> { ... }
fn unbuild(&self, prj: &Self::Project) -> Result<(), Self::Error> { ... }
fn update_repo(
&self,
prj: &Self::Project,
repo: &Repository
) -> Result<(), Self::Error> { ... }
}
Expand description
A trait that concerns itself with the “low level” operations of the project manager, with how things are done.
Required Associated Types§
sourcetype Dirs: Directories
type Dirs: Directories
A type that implements the PMDirs
trait
sourcetype Store: ProjectStore<Self::Project>
type Store: ProjectStore<Self::Project>
A type that implements the ProjectStore
trait for projects of type Self::Project
sourcetype Project: ProjectIface
type Project: ProjectIface
A type that implements the ProjectT
trait
Required Methods§
sourcefn map_store_error(
err: <Self::Store as ProjectStore<Self::Project>>::Error
) -> Self::Error
fn map_store_error(
err: <Self::Store as ProjectStore<Self::Project>>::Error
) -> Self::Error
Map the errors created by your store to project manager errors Typically
Self::Error::Store(err)
sourcefn map_dir_error(err: <Self::Dirs as Directories>::Error) -> Self::Error
fn map_dir_error(err: <Self::Dirs as Directories>::Error) -> Self::Error
Map the errors produced by your PMDirs
implementer to project manager errors
Typically
Self::Error::Dirs(err)
sourcefn get_store(&self) -> &Self::Store
fn get_store(&self) -> &Self::Store
Provide a reference to whatever store you are using. If you are using a structure to implement the project manager and you want your project manager to hold within itself a store then its a easy as
&self.store
sourcefn get_mut_store(&mut self) -> &mut Self::Store
fn get_mut_store(&mut self) -> &mut Self::Store
Provide a mutable reference to the same store
sourcefn get_dirs(&self) -> &Self::Dirs
fn get_dirs(&self) -> &Self::Dirs
Provide a reference to whatever mechanism you are using to implement Directories
sourcefn copy_directory<T: AsRef<Path>, Q: AsRef<Path>>(
&self,
from: T,
to: Q
) -> Result<(), Self::Error>
fn copy_directory<T: AsRef<Path>, Q: AsRef<Path>>(
&self,
from: T,
to: Q
) -> Result<(), Self::Error>
Copy a directory completely from one place to another. With the fs_extra
crate
this function is as easy as
let opts = CopyOptions {
overwrite: true,
copy_inside: true,
..Default::default()
};
dir::copy(from, to, &opts)?;
Ok(())
Provided Methods§
sourcefn switch_branch(
&self,
prj: &Self::Project,
repo: &Repository
) -> Result<(), Self::Error>
fn switch_branch(
&self,
prj: &Self::Project,
repo: &Repository
) -> Result<(), Self::Error>
Change to the branch designated by the project’s reference
Errors
- Finding the object
prj.get_ref_string()
in the repo - Checking out the tree with that object
- If there is no reference to set the head to ->
CommonPMErrors::BadRef
- Setting the head to the head of the reference
sourcefn mv(&self, prj: &Self::Project, path: &Path) -> Result<(), Self::Error>
fn mv(&self, prj: &Self::Project, path: &Path) -> Result<(), Self::Error>
Move from wherever to the projects subdirectory in the sources directory
Errors
- Deleting the directories (in established in
Dirs::new().unwrap().src
orpath
) - Copying the directories
sourcefn update_repo(
&self,
prj: &Self::Project,
repo: &Repository
) -> Result<(), Self::Error>
fn update_repo(
&self,
prj: &Self::Project,
repo: &Repository
) -> Result<(), Self::Error>
Update a repo, getting the latest changes if they can be fast forwarded to, and ensuring that the correct reference is updated
Errors
- Getting the remotes
- Fetching the remotes
- Finding the reference
"FETCH_HEAD"
- Getting the commit to said reference
- Analyzing the merge
- If there is no possibility of solving with Fast Forward, then ->
CommonPMErrors::ImposibleUpdate
- Resolving the merge with Fast-Forward strategy
- Seting the head to the new head