pub(crate) struct PlannedEdits {
root: RepositoryRoot,
files: BTreeMap<RepositoryPath, Edit>,
}Expand description
A set of file snapshots and optional replacements from multiple targets.
Fields§
§root: RepositoryRoot§files: BTreeMap<RepositoryPath, Edit>Implementations§
Source§impl PlannedEdits
impl PlannedEdits
Sourcepub(crate) fn new(root: &RepositoryRoot) -> Self
pub(crate) fn new(root: &RepositoryRoot) -> Self
Start a transaction rooted at a repository.
Sourcepub(crate) fn add(
&mut self,
path: RepositoryPath,
expected: Option<Vec<u8>>,
replacement: Option<Vec<u8>>,
) -> Result<(), EditError>
pub(crate) fn add( &mut self, path: RepositoryPath, expected: Option<Vec<u8>>, replacement: Option<Vec<u8>>, ) -> Result<(), EditError>
Add one repository-relative file snapshot and an optional replacement.
expected = None means the file must not exist yet. replacement = None records a read-only snapshot so other target edits cannot
invalidate it.
Adding the exact same snapshot and replacement for a path already present is a no-op, so an ecosystem adapter that recomputes the same shared edit for multiple units (for example, a Cargo workspace-wide version write shared by several packages) can contribute it once per unit without tracking which unit contributed it first.
§Errors
Returns an error for a path that is a symlink or escapes the root, or for a path already contributed with different expected or replacement content.
Sourcepub(crate) fn compose<E: From<EditError>>(
&mut self,
path: RepositoryPath,
current: &[u8],
render: impl FnOnce(&[u8]) -> Result<Vec<u8>, E>,
) -> Result<(), E>
pub(crate) fn compose<E: From<EditError>>( &mut self, path: RepositoryPath, current: &[u8], render: impl FnOnce(&[u8]) -> Result<Vec<u8>, E>, ) -> Result<(), E>
Rewrite the bytes planned for path, or plan an edit of current
when the path has none yet.
render receives the bytes planned so far, so several contributors
can change one file. The stale check stays on current.
§Errors
Returns the error of render, or an edit error for a path that is a
symlink or escapes the root, or that was planned from other bytes.
Sourcepub(crate) fn apply(&self) -> Result<(), EditError>
pub(crate) fn apply(&self) -> Result<(), EditError>
Check every source snapshot, then apply all replacements in one file transaction.
§Errors
Returns an error if any path changed since planning or safe application fails.
Sourcepub(crate) fn changed_paths(&self) -> Vec<PathBuf>
pub(crate) fn changed_paths(&self) -> Vec<PathBuf>
Return repository-relative paths that this transaction will write.
Trait Implementations§
Source§impl Clone for PlannedEdits
impl Clone for PlannedEdits
Source§fn clone(&self) -> PlannedEdits
fn clone(&self) -> PlannedEdits
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PlannedEdits
impl Debug for PlannedEdits
impl Eq for PlannedEdits
Source§impl PartialEq for PlannedEdits
impl PartialEq for PlannedEdits
impl StructuralPartialEq for PlannedEdits
Auto Trait Implementations§
impl Freeze for PlannedEdits
impl RefUnwindSafe for PlannedEdits
impl Send for PlannedEdits
impl Sync for PlannedEdits
impl Unpin for PlannedEdits
impl UnsafeUnpin for PlannedEdits
impl UnwindSafe for PlannedEdits
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.