pub struct WorkspaceLayout { /* private fields */ }Expand description
Where a workspace keeps its files.
Pure path arithmetic and one directory listing — it opens nothing and locks
nothing. A caller that only needs “which file is work?” (the CLI resolving
--db work) wants this and not the handle pool.
Implementations§
Source§impl WorkspaceLayout
impl WorkspaceLayout
Sourcepub fn new(root: impl Into<PathBuf>) -> Self
pub fn new(root: impl Into<PathBuf>) -> Self
A layout rooted at root. Creates nothing; the directories appear when
a database is first written.
Sourcepub fn path_of(&self, name: &DbName) -> PathBuf
pub fn path_of(&self, name: &DbName) -> PathBuf
The file backing name, <root>/db/<name>.plugmem.
A join of validated components, so the result is always inside
WorkspaceLayout::db_dir.
Sourcepub fn registry_path(&self) -> PathBuf
pub fn registry_path(&self) -> PathBuf
The registry’s file, <root>/registry.plugmem. It sits in the root
rather than beside the databases, so no name can collide with it.
Sourcepub fn exists(&self, name: &DbName) -> bool
pub fn exists(&self, name: &DbName) -> bool
Whether name is a database on disk.
Asks the storage layer rather than stat-ing the path: a database that has been written to but not yet checkpointed has no file at its base path, and treating it as absent would mean creating over it.
Sourcepub fn list(&self) -> Result<Vec<DbName>, WorkspaceError>
pub fn list(&self) -> Result<Vec<DbName>, WorkspaceError>
Every database in the workspace, sorted by name.
Reads the directory — the filesystem is the truth, the registry is only
an index over it. A missing db/ is an empty workspace, not an error.
Files whose name is not a database’s are skipped here and reported by
the registry’s verify, which is where a person is asking about
consistency rather than about what they can open.
One database is several files (chat-42.plugmem, .journal, .lock,
.snap.N), so the listing folds them back to one name each: a name
cannot contain a dot, so everything up to the first dot is the candidate,
and the storage layer confirms whether a database is really there.
§Errors
WorkspaceError::Io if the directory exists but cannot be read.
Trait Implementations§
Source§impl Clone for WorkspaceLayout
impl Clone for WorkspaceLayout
Source§fn clone(&self) -> WorkspaceLayout
fn clone(&self) -> WorkspaceLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WorkspaceLayout
impl Debug for WorkspaceLayout
impl Eq for WorkspaceLayout
Source§impl PartialEq for WorkspaceLayout
impl PartialEq for WorkspaceLayout
impl StructuralPartialEq for WorkspaceLayout
Auto Trait Implementations§
impl Freeze for WorkspaceLayout
impl RefUnwindSafe for WorkspaceLayout
impl Send for WorkspaceLayout
impl Sync for WorkspaceLayout
impl Unpin for WorkspaceLayout
impl UnsafeUnpin for WorkspaceLayout
impl UnwindSafe for WorkspaceLayout
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.