#[non_exhaustive]pub enum Conflict {
StaleRevision {
expected: u64,
found: u64,
},
MissingTarget {
edit: usize,
id: EntityId,
},
IdAlreadyExists {
edit: usize,
id: EntityId,
},
DanglingReference {
edit: usize,
from: EntityId,
slot: usize,
target: EntityId,
},
RemovalWouldDangle {
edit: usize,
removed: EntityId,
referrer: EntityId,
slot: usize,
},
}Expand description
A reason a transaction cannot be committed.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
StaleRevision
The model changed since the transaction was opened.
Optimistic concurrency: two editors read the same model, both plan edits, and the second to commit is working from a view that no longer exists. Rejecting is the only safe answer – the second editor’s preflight was computed against state that has since moved.
Fields
MissingTarget
An edit names an entity that does not exist and is not being created.
Fields
IdAlreadyExists
An insert would overwrite an entity that already exists.
crate::Model::insert deliberately replaces, because a codec
re-reading a file must be able to. A transaction refuses instead: an
author who did not mean to destroy an entity gets told, rather than
discovering it later in a diff.
DanglingReference
An edit writes a reference to an entity that will not exist.
Checked against the PROJECTED model, so referencing an entity the same transaction creates is fine, and referencing one it removes is not.
Fields
RemovalWouldDangle
A removal would leave a surviving entity pointing at nothing.
crate::Model::remove permits this and documents it; a transaction
does not. Deleting a storey that walls still reference produces a file
that parses and is wrong, which is worse than a refused edit.
The fix is to include the referrers’ updates in the same transaction, which is exactly what the projected check allows.
Trait Implementations§
impl Eq for Conflict
Source§impl Error for Conflict
impl Error for Conflict
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()