Struct asciii::storage::Storage
[−]
[src]
pub struct Storage<L: Storable> { /* fields omitted */ }
Manages project file storage.
This includes:
- keeping current projects in a working directory
- listing project folders and files
- listing templates
- archiving and unarchiving projects
- git interaction
Methods
impl<L: Storable> Storage<L>
[src]
fn new<P: AsRef<Path>>(
root: P,
working: &str,
archive: &str,
template: &str
) -> StorageResult<Self>
[src]
root: P,
working: &str,
archive: &str,
template: &str
) -> StorageResult<Self>
Inits storage, does not check existence, yet. TODO
fn new_with_git<P: AsRef<Path>>(
root: P,
working: &str,
archive: &str,
template: &str
) -> StorageResult<Self>
[src]
root: P,
working: &str,
archive: &str,
template: &str
) -> StorageResult<Self>
Inits storage with git capabilities.
fn health_check(&self) -> StorageResult<()>
[src]
Checks whether the folder structure is as it's supposed to be.
fn root_dir(&self) -> &Path
[src]
Getter for Storage::storage.
fn working_dir(&self) -> &Path
[src]
Getter for Storage::working.
fn archive_dir(&self) -> &Path
[src]
Getter for Storage::archive.
fn templates_dir(&self) -> &Path
[src]
Getter for Storage::templates.
fn repository(&self) -> Option<&Repository>
[src]
Getter for Storage::templates.
fn paths(&self) -> Paths
[src]
Returns a struct containing all configured paths of this Storage
.
fn create_dirs(&self) -> StorageResult<()>
[src]
Creates the basic dir structure inside the storage directory.
└── root ├── archive ├── templates └── working
If the directories already exist as expected, that's fine TODO ought to fail when storage_dir already contains directories that do not correspond with the names given in this setup.
fn create_archive(&self, year: Year) -> StorageResult<PathBuf>
[src]
Creates an archive for a certain year. This is a subdirectory under the archive directory.
└── root ├── archive ├── 2001 ...
fn list_template_files(&self) -> StorageResult<Vec<PathBuf>>
[src]
Produces a list of files in the template_dir()
fn list_template_names(&self) -> StorageResult<Vec<String>>
[src]
Produces a list of names of all template filess in the templates_dir()
fn get_template_file(&self, name: &str) -> StorageResult<PathBuf>
[src]
Returns the Path to the template file by the given name, maybe.
fn list_archives(&self) -> StorageResult<Vec<PathBuf>>
[src]
Produces a list of paths to all archives in the archive_dir
.
An archive itself is a folder that contains project dirs,
therefore it essentially has the same structure as the working_dir
,
with the difference, that the project folders may be prefixed with the projects index, e.g.
an invoice number etc.
fn list_years(&self) -> StorageResult<Vec<Year>>
[src]
Produces a list of years for which there is an archive.
fn create_project(
&self,
project_name: &str,
template_name: &str,
fill_data: &HashMap<&str, String>
) -> StorageResult<L>
[src]
&self,
project_name: &str,
template_name: &str,
fill_data: &HashMap<&str, String>
) -> StorageResult<L>
Takes a template file and stores it in the working directory, in a new project directory according to it's name.
fn archive_project(
&self,
project: &L,
year: Year
) -> StorageResult<Vec<PathBuf>>
[src]
&self,
project: &L,
year: Year
) -> StorageResult<Vec<PathBuf>>
Moves a project folder from /working
dir to /archive/$year
.
Also adds the project.prefix() to the folder name.
└── root ├── archive ├── 2001 ├── R0815_Birthdayparty ...
fn archive_projects_if<F>(
&self,
search_terms: &[&str],
manual_year: Option<i32>,
confirm: F
) -> StorageResult<Vec<PathBuf>> where
F: Fn() -> bool,
[src]
&self,
search_terms: &[&str],
manual_year: Option<i32>,
confirm: F
) -> StorageResult<Vec<PathBuf>> where
F: Fn() -> bool,
Moves projects found through search_terms
from the Working
directory to the Archive
/year
directory.
Returns list of old and new paths.
fn delete_project_if<F>(&self, project: &L, confirmed: F) -> StorageResult<()> where
F: Fn() -> bool,
[src]
F: Fn() -> bool,
fn unarchive_projects(
&self,
year: i32,
search_terms: &[&str]
) -> StorageResult<Vec<PathBuf>>
[src]
&self,
year: i32,
search_terms: &[&str]
) -> StorageResult<Vec<PathBuf>>
Moves projects found through search_terms
from the year
back to the Working
directory.
Returns list of old and new paths.
fn unarchive_project(&self, project: &L) -> StorageResult<PathBuf>
[src]
Moves a project folder from /working
dir to /archive/$year
.
fn unarchive_project_dir(&self, archived_dir: &Path) -> StorageResult<PathBuf>
[src]
Moves a project folder from /working
dir to /archive/$year
.
fn search_projects(
&self,
directory: StorageDir,
search_term: &str
) -> StorageResult<ProjectList<L>>
[src]
&self,
directory: StorageDir,
search_term: &str
) -> StorageResult<ProjectList<L>>
Matches StorageDir's content against a term and returns matching project files.
This only searches by name
TODO return opened Project
, no need to reopen
Warning
Please be adviced that this uses Storage::open_projects()
and therefore opens all projects.
fn search_projects_any(
&self,
dir: StorageDir,
search_terms: &[&str]
) -> StorageResult<ProjectList<L>>
[src]
&self,
dir: StorageDir,
search_terms: &[&str]
) -> StorageResult<ProjectList<L>>
Matches StorageDir's content against multiple terms and returns matching projects. TODO add search_multiple_projects_deep
fn get_project_dir(
&self,
name: &str,
directory: StorageDir
) -> StorageResult<PathBuf>
[src]
&self,
name: &str,
directory: StorageDir
) -> StorageResult<PathBuf>
Tries to find a concrete Project.
fn get_project_file(&self, directory: &Path) -> StorageResult<PathBuf>
[src]
Locates the project file inside a folder.
This is the first file with the super::PROJECT_FILE_EXTENSION
in the folder
fn list_project_folders(
&self,
directory: StorageDir
) -> StorageResult<Vec<PathBuf>>
[src]
&self,
directory: StorageDir
) -> StorageResult<Vec<PathBuf>>
Produces a list of project folders.
fn list_empty_project_dirs(
&self,
directory: StorageDir
) -> StorageResult<Vec<PathBuf>>
[src]
&self,
directory: StorageDir
) -> StorageResult<Vec<PathBuf>>
Produces a list of empty project folders.
fn list_project_files(
&self,
directory: StorageDir
) -> StorageResult<Vec<PathBuf>>
[src]
&self,
directory: StorageDir
) -> StorageResult<Vec<PathBuf>>
Produces a list of project files.
fn filter_project_files<F>(
&self,
directory: StorageDir,
filter: F
) -> StorageResult<Vec<PathBuf>> where
F: FnMut(&PathBuf) -> bool,
[src]
&self,
directory: StorageDir,
filter: F
) -> StorageResult<Vec<PathBuf>> where
F: FnMut(&PathBuf) -> bool,
fn open_projects<I>(&self, selection: I) -> StorageResult<ProjectList<L>> where
I: Into<StorageSelection>,
[src]
I: Into<StorageSelection>,
Behaves like list_project_files()
but also opens projects directly.
fn open_projects_dir(
&self,
directory: StorageDir
) -> StorageResult<ProjectList<L>>
[src]
&self,
directory: StorageDir
) -> StorageResult<ProjectList<L>>
Behaves like list_project_files()
but also opens projects directly.