Skip to main content

Workspace

Struct Workspace 

Source
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>

Source

pub fn branch_id(&self) -> Id

Returns the branch id associated with this workspace.

Source

pub fn head(&self) -> Option<CommitHandle>

Returns the current commit handle if one exists.

Source

pub fn metadata(&self) -> Value<Handle<Blake3, SimpleArchive>>

Returns the workspace metadata handle.

Source

pub fn put<S, T>(&mut self, item: T) -> Value<Handle<Blake3, S>>
where S: BlobSchema + 'static, T: ToBlob<S>, Handle<Blake3, S>: ValueSchema,

Adds a blob to the workspace’s local blob store. Mirrors BlobStorePut::put for ease of use.

Source

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>>
where S: BlobSchema + 'static, T: TryFromBlob<S>, Handle<Blake3, S>: ValueSchema,

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.

Source

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.

Source

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.

Source

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) into self.local_blobs, then create a merge commit whose parents are self.head and other.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 via repo::transfer(reachable(...))).
  • This design keeps merge permissive and leaves cross-repository blob import as an explicit user action.
Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl<Blobs> Debug for Workspace<Blobs>
where Blobs: BlobStore<Blake3>, Blobs::Reader: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>
where <Blobs as BlobStore<Hasher>>::Reader: Unpin,

§

impl<Blobs> UnsafeUnpin for Workspace<Blobs>
where <Blobs as BlobStore<Hasher>>::Reader: UnsafeUnpin,

§

impl<Blobs> !UnwindSafe for Workspace<Blobs>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V