pub struct WorkspaceId(/* private fields */);Expand description
A workspace identifier.
Stable across sessions and across machines. Two mechanisms exist
(per docs/concepts/workspace-model.md § 3):
- Git-backed —
WorkspaceId::from_git_remote(origin_url)produces a deterministic hash of the normalised remote URL. Branch is not part of the ID by default; all branches of a repo share one workspace. - Non-git —
WorkspaceId::from_ulid(Ulid)creates an explicit identifier for workspaces not backed by a git repo.
§Examples
use mimir_core::WorkspaceId;
let a = WorkspaceId::from_git_remote("git@github.com:buildepicshit/Mimir.git").unwrap();
let b = WorkspaceId::from_git_remote("https://github.com/buildepicshit/Mimir").unwrap();
// The normalisation collapses scheme and trailing `.git` so equivalent
// remotes resolve to equivalent workspace IDs where host+path match.
// (Exact normalisation rules live in §§ 3.1 of workspace-model.md.)
assert_ne!(a, b); // SSH and HTTPS remotes with different hosts do differ.Implementations§
Source§impl WorkspaceId
impl WorkspaceId
Sourcepub fn from_git_remote(origin_url: &str) -> Result<Self, WorkspaceIdError>
pub fn from_git_remote(origin_url: &str) -> Result<Self, WorkspaceIdError>
Compute a workspace ID from a git origin remote URL.
Normalisation performed before hashing:
- Trim surrounding whitespace.
- Lowercase the whole URL.
- Strip any trailing
.gitsuffix. - Strip any trailing slash.
Branch is intentionally not included (see workspace-model.md § 3.1).
§Errors
Returns WorkspaceIdError::EmptyRemote if the URL is empty after
normalisation.
Sourcepub fn from_ulid(ulid: Ulid) -> Self
pub fn from_ulid(ulid: Ulid) -> Self
Construct from an explicit ULID — for non-git workspaces created
via mimir init --workspace <name> (see workspace-model.md § 3.2).
Sourcepub fn detect_from_path(start: &Path) -> Result<Self, WorkspaceError>
pub fn detect_from_path(start: &Path) -> Result<Self, WorkspaceError>
Walk up from start looking for a .git/ directory and, on
finding one, read origin remote URL from .git/config and
hash it per WorkspaceId::from_git_remote.
Implements workspace-model.md § 3.3 step 1 (git-backed
workspaces). Returns WorkspaceError::NoActiveWorkspace if
the walk reaches the filesystem root without finding .git/.
§Errors
WorkspaceError::Ioon filesystem read failure.WorkspaceError::NoActiveWorkspaceif no.git/is found.WorkspaceError::NoOriginRemoteif the config has no[remote "origin"] url = ...entry.WorkspaceError::InvalidRemoteif the origin URL normalises to an empty string.
Trait Implementations§
Source§impl Clone for WorkspaceId
impl Clone for WorkspaceId
Source§fn clone(&self) -> WorkspaceId
fn clone(&self) -> WorkspaceId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WorkspaceId
impl Debug for WorkspaceId
Source§impl Display for WorkspaceId
impl Display for WorkspaceId
Source§impl Hash for WorkspaceId
impl Hash for WorkspaceId
Source§impl PartialEq for WorkspaceId
impl PartialEq for WorkspaceId
impl Copy for WorkspaceId
impl Eq for WorkspaceId
impl StructuralPartialEq for WorkspaceId
Auto Trait Implementations§
impl Freeze for WorkspaceId
impl RefUnwindSafe for WorkspaceId
impl Send for WorkspaceId
impl Sync for WorkspaceId
impl Unpin for WorkspaceId
impl UnsafeUnpin for WorkspaceId
impl UnwindSafe for WorkspaceId
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.