honeycomb_core::attributes

Trait AttributeStorage

Source
pub trait AttributeStorage<A: AttributeBind>: UnknownAttributeStorage {
    // Required methods
    fn read(
        &self,
        trans: &mut Transaction,
        id: A::IdentifierType,
    ) -> StmResult<Option<A>>;
    fn write(
        &self,
        trans: &mut Transaction,
        id: A::IdentifierType,
        val: A,
    ) -> StmResult<Option<A>>;
    fn remove(
        &self,
        trans: &mut Transaction,
        id: A::IdentifierType,
    ) -> StmResult<Option<A>>;
    fn force_write(&self, id: A::IdentifierType, val: A) -> Option<A>;

    // Provided methods
    fn force_read(&self, id: A::IdentifierType) -> Option<A> { ... }
    fn force_remove(&self, id: A::IdentifierType) -> Option<A> { ... }
}
Expand description

Common trait implemented by generic attribute storages.

This trait contain attribute-specific methods.

The documentation of this trait describe the behavior each function & method should have. “ID” and “index” are used interchangeably.

§Note on force / regular semantics

We define two variants of read / write / remove methods: force and regular. Their goal is to provide different degrees of control vs convenience when using these operations. Documentation of each method shortly explains their individual quirks, below is a table summarizing the differences:

variantdescription
regularregular impl, which will fail if the transaction fails
forceconvenience impl, which wraps the regular impl in a transaction that retries until success

Required Methods§

Source

fn read( &self, trans: &mut Transaction, id: A::IdentifierType, ) -> StmResult<Option<A>>

Read the value of an element at a given index.

§Arguments
  • trans: &mut Transaction – Transaction used for synchronization.
  • index: A::IdentifierType – Cell index.
§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. The result should not be processed manually, only used via the ? operator.

§Panics

The method:

  • should panic if the index lands out of bounds
  • may panic if the index cannot be converted to usize
Source

fn write( &self, trans: &mut Transaction, id: A::IdentifierType, val: A, ) -> StmResult<Option<A>>

Write the value of an element at a given index and return the old value.

§Arguments
  • trans: &mut Transaction – Transaction used for synchronization.
  • index: A::IdentifierType – Cell index.
  • val: A – Attribute value.
§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. The result should not be processed manually, only used via the ? operator.

§Panics

The method:

  • should panic if the index lands out of bounds
  • may panic if the index cannot be converted to usize
Source

fn remove( &self, trans: &mut Transaction, id: A::IdentifierType, ) -> StmResult<Option<A>>

Remove the value at a given index and return it.

§Arguments
  • trans: &mut Transaction – Transaction used for synchronization.
  • index: A::IdentifierType – Cell index.
§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. The result should not be processed manually, only used via the ? operator.

§Panics

The method:

  • should panic if the index lands out of bounds
  • may panic if the index cannot be converted to usize
Source

fn force_write(&self, id: A::IdentifierType, val: A) -> Option<A>

Write the value of an element at a given index and return the old value.

This variant is equivalent to write, but internally uses a transaction that will be retried until validated.

Provided Methods§

Source

fn force_read(&self, id: A::IdentifierType) -> Option<A>

Read the value of an element at a given index.

This variant is equivalent to read, but internally uses a transaction that will be retried until validated.

Source

fn force_remove(&self, id: A::IdentifierType) -> Option<A>

Remove the value at a given index and return it.

This variant is equivalent to remove, but internally uses a transaction that will be retried until validated.

Implementors§