pub struct Changeset { /* private fields */ }Expand description
A unit of change applied as a single commit.
Implementations§
Source§impl Changeset
impl Changeset
Sourcepub fn upsert(
self,
path: impl Into<String>,
content: impl Into<Vec<u8>>,
) -> Self
pub fn upsert( self, path: impl Into<String>, content: impl Into<Vec<u8>>, ) -> Self
Add or overwrite a file.
Sourcepub fn with_change(self, change: TreeChange) -> Self
pub fn with_change(self, change: TreeChange) -> Self
Add an arbitrary TreeChange.
Sourcepub fn expect_blob(self, path: impl Into<String>, blob: Oid) -> Self
pub fn expect_blob(self, path: impl Into<String>, blob: Oid) -> Self
Require path to currently hold blob (an update of known content).
Sourcepub fn expect_absent(self, path: impl Into<String>) -> Self
pub fn expect_absent(self, path: impl Into<String>) -> Self
Require path to currently be absent (a create).
Sourcepub fn with_precondition(self, precondition: Precondition) -> Self
pub fn with_precondition(self, precondition: Precondition) -> Self
Add an arbitrary Precondition (e.g. over a page read but not written,
extending the multi-file CAS to the changeset’s read set).
Sourcepub fn create(
self,
path: impl Into<String>,
content: impl Into<Vec<u8>>,
) -> Self
pub fn create( self, path: impl Into<String>, content: impl Into<Vec<u8>>, ) -> Self
Create a new file. Precondition: path must currently be absent.
Aborts the changeset if the path exists.
Sourcepub fn update(
self,
path: impl Into<String>,
content: impl Into<Vec<u8>>,
expected: Oid,
) -> Self
pub fn update( self, path: impl Into<String>, content: impl Into<Vec<u8>>, expected: Oid, ) -> Self
Update an existing file. Precondition: path must currently hold
expected (the version token the caller read). Protects against lost
updates — a concurrent change to path aborts the changeset.
Sourcepub fn delete(self, path: impl Into<String>, expected: Oid) -> Self
pub fn delete(self, path: impl Into<String>, expected: Oid) -> Self
Delete an existing file. Precondition: it must currently hold expected.
Aborts if the file changed or is absent since the caller read it.
Sourcepub fn rename(
self,
from: impl Into<String>,
to: impl Into<String>,
content: impl Into<Vec<u8>>,
expected_from: Oid,
) -> Self
pub fn rename( self, from: impl Into<String>, to: impl Into<String>, content: impl Into<Vec<u8>>, expected_from: Oid, ) -> Self
Atomic rename: move from (which must currently hold expected_from)
to to (which must currently be absent), as one commit. Both
endpoints get preconditions. content is the bytes to write at to —
usually the caller passes the source’s bytes unchanged for a pure
rename; passing different bytes is a rename-and-modify. Chain
.update()/.upsert() after this for link-target updates in the same
commit (move + link-updates is atomic).
Sourcepub fn touched_paths(&self) -> Vec<String>
pub fn touched_paths(&self) -> Vec<String>
turbovault-lri: enumerate the paths this changeset mutates so
higher layers can apply policies like the include_ignored
gitignore-refusal check before submission. Same content as the
private changed_paths helper; exposed for consumers in
turbovault-tools.