pub struct Workspace<Blobs: BlobStore<Blake3>> { /* private fields */ }Expand description
The Workspace represents the mutable working area or “staging” state.
It was formerly known as Head. It is sent to worker threads,
modified (via commits, merges, etc.), and then merged back into the Repository.
Implementations§
Source§impl<Blobs: BlobStore<Blake3>> Workspace<Blobs>
impl<Blobs: BlobStore<Blake3>> Workspace<Blobs>
Sourcepub fn head(&self) -> Option<CommitHandle>
pub fn head(&self) -> Option<CommitHandle>
Returns the current commit handle if one exists.
Sourcepub fn metadata(&self) -> Value<Handle<Blake3, SimpleArchive>>
pub fn metadata(&self) -> Value<Handle<Blake3, SimpleArchive>>
Returns the workspace metadata handle.
Sourcepub fn put<S, T>(&mut self, item: T) -> Value<Handle<Blake3, S>>
pub fn put<S, T>(&mut self, item: T) -> Value<Handle<Blake3, S>>
Adds a blob to the workspace’s local blob store.
Mirrors BlobStorePut::put for ease of use.
Sourcepub fn get<T, S>(
&mut self,
handle: Value<Handle<Blake3, S>>,
) -> Result<T, <Blobs::Reader as BlobStoreGet<Blake3>>::GetError<<T as TryFromBlob<S>>::Error>>
pub fn get<T, S>( &mut self, handle: Value<Handle<Blake3, S>>, ) -> Result<T, <Blobs::Reader as BlobStoreGet<Blake3>>::GetError<<T as TryFromBlob<S>>::Error>>
Retrieves a blob from the workspace.
The method first checks the workspace’s local blob store and falls back to the base blob store if the blob is not found locally.
Sourcepub fn commit(&mut self, content_: impl Into<TribleSet>, message_: &str)
pub fn commit(&mut self, content_: impl Into<TribleSet>, message_: &str)
Performs a commit in the workspace. This method creates a new commit blob (stored in the local blobset) and updates the current commit handle.
Sourcepub fn commit_with_metadata(
&mut self,
content_: impl Into<TribleSet>,
metadata_: Value<Handle<Blake3, SimpleArchive>>,
message_: &str,
)
pub fn commit_with_metadata( &mut self, content_: impl Into<TribleSet>, metadata_: Value<Handle<Blake3, SimpleArchive>>, message_: &str, )
Like commit but attaches a one-off metadata handle
instead of the repository default.
Sourcepub fn merge(
&mut self,
other: &mut Workspace<Blobs>,
) -> Result<CommitHandle, MergeError>
pub fn merge( &mut self, other: &mut Workspace<Blobs>, ) -> Result<CommitHandle, MergeError>
Merge another workspace (or its commit state) into this one.
Notes on semantics
- This operation will copy the staged blobs created in
other(i.e.,other.local_blobs) intoself.local_blobs, then create a merge commit whose parents areself.headandother.head. - The merge does not automatically import the entire base history
reachable from
other’s head. If the incoming parent commits reference blobs that do not exist in this repository’s storage, reading those commits later will fail until the missing blobs are explicitly imported (for example viarepo::transfer(reachable(...))). - This design keeps merge permissive and leaves cross-repository blob import as an explicit user action.
Sourcepub fn merge_commit(
&mut self,
other: Value<Handle<Blake3, SimpleArchive>>,
) -> Result<CommitHandle, MergeError>
pub fn merge_commit( &mut self, other: Value<Handle<Blake3, SimpleArchive>>, ) -> Result<CommitHandle, MergeError>
Create a merge commit that ties this workspace’s current head and an
arbitrary other commit (already present in the underlying blob store)
together without requiring another Workspace instance.
This does not attach any content to the merge commit.
Sourcepub fn checkout<R>(
&mut self,
spec: R,
) -> Result<Checkout, WorkspaceCheckoutError<<Blobs::Reader as BlobStoreGet<Blake3>>::GetError<UnarchiveError>>>where
R: CommitSelector<Blobs>,
pub fn checkout<R>(
&mut self,
spec: R,
) -> Result<Checkout, WorkspaceCheckoutError<<Blobs::Reader as BlobStoreGet<Blake3>>::GetError<UnarchiveError>>>where
R: CommitSelector<Blobs>,
Returns the combined TribleSet for the specified commits or commit
ranges. spec can be a single CommitHandle, an iterator of handles
or any of the standard range types over CommitHandle.
Sourcepub fn checkout_metadata<R>(
&mut self,
spec: R,
) -> Result<TribleSet, WorkspaceCheckoutError<<Blobs::Reader as BlobStoreGet<Blake3>>::GetError<UnarchiveError>>>where
R: CommitSelector<Blobs>,
pub fn checkout_metadata<R>(
&mut self,
spec: R,
) -> Result<TribleSet, WorkspaceCheckoutError<<Blobs::Reader as BlobStoreGet<Blake3>>::GetError<UnarchiveError>>>where
R: CommitSelector<Blobs>,
Returns the combined metadata TribleSet for the specified commits.
Commits without metadata handles contribute an empty set.
Sourcepub fn checkout_with_metadata<R>(
&mut self,
spec: R,
) -> Result<(TribleSet, TribleSet), WorkspaceCheckoutError<<Blobs::Reader as BlobStoreGet<Blake3>>::GetError<UnarchiveError>>>where
R: CommitSelector<Blobs>,
pub fn checkout_with_metadata<R>(
&mut self,
spec: R,
) -> Result<(TribleSet, TribleSet), WorkspaceCheckoutError<<Blobs::Reader as BlobStoreGet<Blake3>>::GetError<UnarchiveError>>>where
R: CommitSelector<Blobs>,
Returns the combined data and metadata TribleSet for the specified commits.
Metadata is loaded from each commit’s metadata handle, when present.
Trait Implementations§
Auto Trait Implementations§
impl<Blobs> !Freeze for Workspace<Blobs>
impl<Blobs> !RefUnwindSafe for Workspace<Blobs>
impl<Blobs> Send for Workspace<Blobs>
impl<Blobs> !Sync for Workspace<Blobs>
impl<Blobs> Unpin for Workspace<Blobs>
impl<Blobs> UnsafeUnpin for Workspace<Blobs>
impl<Blobs> !UnwindSafe for Workspace<Blobs>
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> 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