pub struct EntityEditor<'a> { /* private fields */ }Expand description
A schema-checked edit of one entity already present in a Model.
Named edits are resolved against the entity’s declaration and the entire
projected entity is validated before any write is staged. Reference
integrity, stale revisions, and atomic commit remain Transaction’s
responsibility.
Implementations§
Source§impl<'a> EntityEditor<'a>
impl<'a> EntityEditor<'a>
Sourcepub fn new(
schema: &'a Schema,
model: &Model,
id: EntityId,
) -> AuthorResult<Self>
pub fn new( schema: &'a Schema, model: &Model, id: EntityId, ) -> AuthorResult<Self>
Start editing id against the model snapshot used to open a transaction.
§Errors
Returns AuthorError::MissingEntity when id is absent. A caller
should create its Transaction from the same model snapshot.
Sourcepub fn set(self, attribute: impl Into<String>, value: Value) -> Self
pub fn set(self, attribute: impl Into<String>, value: Value) -> Self
Replace one attribute by its declared name.
Sourcepub fn text(
self,
attribute: impl Into<String>,
text: impl Into<Arc<str>>,
) -> Self
pub fn text( self, attribute: impl Into<String>, text: impl Into<Arc<str>>, ) -> Self
Replace a text attribute.
Sourcepub fn real(self, attribute: impl Into<String>, value: f64) -> Self
pub fn real(self, attribute: impl Into<String>, value: f64) -> Self
Replace a real-valued attribute.
Sourcepub fn reference(self, attribute: impl Into<String>, id: EntityId) -> Self
pub fn reference(self, attribute: impl Into<String>, id: EntityId) -> Self
Replace an entity-reference attribute.
Sourcepub fn enumeration(
self,
attribute: impl Into<String>,
constant: impl Into<Arc<str>>,
) -> Self
pub fn enumeration( self, attribute: impl Into<String>, constant: impl Into<Arc<str>>, ) -> Self
Replace an enumeration attribute.
Sourcepub fn stage(self, transaction: &mut Transaction) -> AuthorResult<()>
pub fn stage(self, transaction: &mut Transaction) -> AuthorResult<()>
Validate the projected entity and stage its changed slots.
Validation completes before the first call to Transaction::set_attribute,
so any AuthorError leaves transaction unchanged.