Skip to main content

WriteTransaction

Struct WriteTransaction 

Source
pub struct WriteTransaction<'db> { /* private fields */ }
Expand description

Single writer transaction.

§Performance

Moving a writer is O(database state size).

Implementations§

Source§

impl WriteTransaction<'_>

Source

pub fn register_role( &mut self, name: impl Into<String>, ) -> Result<RoleId, DbError>

Registers a structural incidence role.

§Errors

Returns DbError when the name already exists or ID allocation fails.

§Performance

This method is O(log role count + name length).

Source

pub fn register_label( &mut self, name: impl Into<String>, ) -> Result<LabelId, DbError>

Registers an element or relation label.

§Errors

Returns DbError when the name already exists or ID allocation fails.

§Performance

This method is O(log label count + name length).

Source

pub fn register_relation_type( &mut self, name: impl Into<String>, ) -> Result<RelationTypeId, DbError>

Registers a relation type.

§Errors

Returns DbError when the name already exists or ID allocation fails.

§Performance

This method is O(log relation type count + name length).

Source

pub fn register_property_key( &mut self, name: impl Into<String>, family: PropertyFamily, value_type: PropertyType, ) -> Result<PropertyKeyId, DbError>

Registers a typed property key.

§Errors

Returns DbError when the name already exists or ID allocation fails.

§Performance

This method is O(log property key count + name length).

Source

pub fn define_projection( &mut self, definition: ProjectionDefinition, ) -> Result<ProjectionId, DbError>

Defines a physical projection.

§Errors

Returns DbError when referenced catalog IDs are unknown, the projection name already exists, or ID allocation fails.

§Performance

This method is O(definition size + catalog lookup cost).

Source

pub fn define_index( &mut self, name: impl Into<String>, definition: IndexDefinition, ) -> Result<IndexId, DbError>

Defines an index.

§Errors

Returns DbError when referenced catalog IDs are unknown, the index name already exists, or ID allocation fails.

§Performance

This method is O(definition size + catalog lookup cost).

Source

pub fn create_element(&mut self) -> Result<ElementId, DbError>

Creates a canonical element.

§Errors

Returns DbError::IdOverflow when element IDs are exhausted.

§Performance

This method is O(log element count).

Source

pub fn create_relation(&mut self) -> Result<RelationId, DbError>

Creates a canonical relation.

§Errors

Returns DbError::IdOverflow when relation IDs are exhausted.

§Performance

This method is O(log relation count).

Source

pub fn create_incidence( &mut self, relation: RelationId, element: ElementId, role: RoleId, ) -> Result<IncidenceId, DbError>

Creates a canonical incidence.

§Errors

Returns DbError when referenced IDs are unknown or incidence IDs are exhausted.

§Performance

This method is O(log incidence count + reference lookup cost).

Source

pub fn tombstone_element(&mut self, id: ElementId) -> Result<(), DbError>

Tombstones a canonical element and its incidences.

§Errors

Returns DbError::UnknownElement when the element is not visible.

§Performance

This method is O(incidence count).

Source

pub fn tombstone_relation(&mut self, id: RelationId) -> Result<(), DbError>

Tombstones a canonical relation and its incidences.

§Errors

Returns DbError::UnknownRelation when the relation is not visible.

§Performance

This method is O(incidence count).

Source

pub fn tombstone_incidence(&mut self, id: IncidenceId) -> Result<(), DbError>

Tombstones a canonical incidence.

§Errors

Returns DbError::UnknownIncidence when the incidence is not visible.

§Performance

This method is O(log incidence count).

Source

pub fn add_element_label( &mut self, element: ElementId, label: LabelId, ) -> Result<(), DbError>

Adds a label to an element.

§Errors

Returns DbError when the element or label is unknown.

§Performance

This method is O(log element count + log label count).

Source

pub fn add_relation_label( &mut self, relation: RelationId, label: LabelId, ) -> Result<(), DbError>

Adds a label to a relation.

§Errors

Returns DbError when the relation or label is unknown.

§Performance

This method is O(log relation count + log label count).

Source

pub fn set_relation_type( &mut self, relation: RelationId, relation_type: RelationTypeId, ) -> Result<(), DbError>

Sets a relation type.

§Errors

Returns DbError when the relation or relation type is unknown.

§Performance

This method is O(log relation count + log relation type count).

Source

pub fn set_property( &mut self, subject: PropertySubject, key: PropertyKeyId, value: PropertyValue, ) -> Result<(), DbError>

Sets a property value.

§Errors

Returns DbError when the subject or key is unknown, or the value does not match the key schema.

§Performance

This method is O(log subject count + log key count).

Source

pub fn remove_property( &mut self, subject: PropertySubject, key: PropertyKeyId, ) -> Result<(), DbError>

Removes a property value.

§Errors

Returns DbError when the subject or key is unknown.

§Performance

This method is O(log subject count + log key count).

Source

pub fn commit(self) -> Result<CommitSeq, DbError>

Commits this write transaction durably.

§Errors

Returns DbError when commit sequence allocation, validation, encoding, writing, or store replacement fails.

§Performance

This method is O(serialized database bytes).

Source

pub fn rollback(self)

Drops this write transaction without committing.

§Performance

This method is O(1) excluding staged-state drop cost.

Auto Trait Implementations§

§

impl<'db> Freeze for WriteTransaction<'db>

§

impl<'db> RefUnwindSafe for WriteTransaction<'db>

§

impl<'db> Send for WriteTransaction<'db>

§

impl<'db> Sync for WriteTransaction<'db>

§

impl<'db> Unpin for WriteTransaction<'db>

§

impl<'db> UnsafeUnpin for WriteTransaction<'db>

§

impl<'db> !UnwindSafe for WriteTransaction<'db>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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