Skip to main content

Changeset

Struct Changeset 

Source
pub struct Changeset { /* private fields */ }
Expand description

A unit of change applied as a single commit.

Implementations§

Source§

impl Changeset

Source

pub fn new(message: impl Into<String>) -> Self

Start a changeset with a commit message.

Source

pub fn upsert( self, path: impl Into<String>, content: impl Into<Vec<u8>>, ) -> Self

Add or overwrite a file.

Source

pub fn remove(self, path: impl Into<String>) -> Self

Remove a file.

Source

pub fn with_change(self, change: TreeChange) -> Self

Add an arbitrary TreeChange.

Source

pub fn expect_blob(self, path: impl Into<String>, blob: Oid) -> Self

Require path to currently hold blob (an update of known content).

Source

pub fn expect_absent(self, path: impl Into<String>) -> Self

Require path to currently be absent (a create).

Source

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).

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Trait Implementations§

Source§

impl Clone for Changeset

Source§

fn clone(&self) -> Changeset

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Changeset

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Changeset

Source§

fn default() -> Changeset

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more