pub struct Store { /* private fields */ }Expand description
A store directory: the workspaces and profiles of one installation.
Implementations§
Source§impl Store
impl Store
Sourcepub fn new(root: impl Into<PathBuf>) -> Self
pub fn new(root: impl Into<PathBuf>) -> Self
The store at root. Nothing is read or written until it is asked for.
Sourcepub fn profiles_dir(&self) -> PathBuf
pub fn profiles_dir(&self) -> PathBuf
The folder the profile definitions live in.
Sourcepub fn workspaces_dir(&self) -> PathBuf
pub fn workspaces_dir(&self) -> PathBuf
The folder the workspaces live in.
Sourcepub fn prepare(&self) -> Result<(), Diagnostic>
pub fn prepare(&self) -> Result<(), Diagnostic>
Creates the folders the store needs, and proves they can be written.
Safe to call at every start: a store that is already there is left alone.
§Errors
A diagnostic naming the directory and the reason, when it cannot be created or written.
Sourcepub fn adopt(&self) -> Vec<Diagnostic>
pub fn adopt(&self) -> Vec<Diagnostic>
Gives every name this store carries from an older QCode the name it has today: Projects/
becomes Workspaces/, and inside each workspace project.qcode becomes workspace.qcode,
Project/ and then Code/ become Work/, and Backup/Project.git becomes
Backup/Code.git.
Each move is a single rename, so an interruption leaves the old name whole rather than two halves, and nothing is renamed onto something that is there already: a store holding both names is left as it is and said. Safe to call at every start — a store with none of the old names only looks.
Sourcepub fn workspace_paths(&self, id: &WorkspaceId) -> WorkspacePaths
pub fn workspace_paths(&self, id: &WorkspaceId) -> WorkspacePaths
Where everything of the workspace id is, whether or not it exists yet.
Sourcepub fn paths_of(&self, file: &WorkspaceFile) -> WorkspacePaths
pub fn paths_of(&self, file: &WorkspaceFile) -> WorkspacePaths
Where everything of the workspace file describes is: Store::workspace_paths, with the
person’s own folder as the code folder when the workspace works in one where it stands.
Everything that opens a workspace reads its folders from here, so the file tree, the shell, every container’s work folder and the backup all see the same folder.
Sourcepub fn create_workspace(
&self,
name: &str,
created: Date,
) -> Result<WorkspaceFile, NewWorkspaceError>
pub fn create_workspace( &self, name: &str, created: Date, ) -> Result<WorkspaceFile, NewWorkspaceError>
Makes a workspace the user called name and gives it the tree of the design.
§Errors
NewWorkspaceError::Name when the name yields no identifier, NewWorkspaceError::Taken
when a folder of that identifier is already there — including one that only differs in
case, which a file system that ignores case would treat as the same folder — and
NewWorkspaceError::Blocked when the store cannot be written.
Sourcepub fn create_workspace_in(
&self,
name: &str,
created: Date,
folder: Option<PathBuf>,
) -> Result<WorkspaceFile, NewWorkspaceError>
pub fn create_workspace_in( &self, name: &str, created: Date, folder: Option<PathBuf>, ) -> Result<WorkspaceFile, NewWorkspaceError>
Makes a workspace the user called name that works in folder where it stands, or in a
Work/ of its own when folder is None.
The person’s folder is only named in the workspace file: nothing is made, moved or written in it.
§Errors
Sourcepub fn write_workspace(&self, file: &WorkspaceFile) -> Result<(), Diagnostic>
pub fn write_workspace(&self, file: &WorkspaceFile) -> Result<(), Diagnostic>
Writes a workspace’s workspace.qcode atomically and makes sure its folders — including one
per profile it names — are there.
§Errors
A diagnostic naming the directory or file that could not be written.
Sourcepub fn read_workspace(&self, id: &WorkspaceId) -> Loaded<Option<WorkspaceFile>>
pub fn read_workspace(&self, id: &WorkspaceId) -> Loaded<Option<WorkspaceFile>>
Reads one workspace’s workspace.qcode.
Sourcepub fn workspaces(&self) -> Loaded<Vec<WorkspaceEntry>>
pub fn workspaces(&self) -> Loaded<Vec<WorkspaceEntry>>
Every workspace folder of the store, sorted by folder name.
A folder that is broken or half-made is listed with its problems rather than left out: the user cannot repair what the list refuses to show. A store that cannot be read at all yields an empty list and one diagnostic.
Sourcepub fn profiles(&self) -> Loaded<Vec<Profile>>
pub fn profiles(&self) -> Loaded<Vec<Profile>>
Every profile definition of the store, sorted by file name.
A Profiles/ folder that is not there yet is not a problem: it means no profiles. A file
that cannot be read or cannot be understood is reported and the rest are still returned,
so one broken definition never hides the profiles that work.
Custom profiles live in Store::custom_profiles_dir, which is read as well: their parts
are their own, and a QCode older than that folder does not see them at all.
Sourcepub fn custom_profiles_dir(&self) -> PathBuf
pub fn custom_profiles_dir(&self) -> PathBuf
The folder a custom profile’s definition file is in.
Sourcepub fn profile_file(&self, profile: &Profile) -> PathBuf
pub fn profile_file(&self, profile: &Profile) -> PathBuf
The folder profile’s definition file is in, and its name: a ready-made template’s is the
one every profile’s file has always been in, and a custom one’s is the folder of its own,
which a QCode that does not know it never reads.
Sourcepub fn write_profile(&self, profile: &Profile) -> Result<(), Diagnostic>
pub fn write_profile(&self, profile: &Profile) -> Result<(), Diagnostic>
Writes a profile’s definition file atomically, making the store’s folders first, and takes away the file of the kind it is not: a profile has one definition, whichever folder holds it, and two of them would list it twice.
§Errors
A diagnostic naming the folder or file that could not be written.
Trait Implementations§
impl Eq for Store
impl StructuralPartialEq for Store
Auto Trait Implementations§
impl Freeze for Store
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl UnwindSafe for Store
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more