pub trait AttributeStorage<A: AttributeBind>: UnknownAttributeStorage {
// Required methods
fn set(&self, id: A::IdentifierType, val: A);
fn set_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
val: A,
) -> Result<(), StmError>;
fn get(&self, id: A::IdentifierType) -> Option<A>;
fn get_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
) -> Result<Option<A>, StmError>;
fn replace(&self, id: A::IdentifierType, val: A) -> Option<A>;
fn replace_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
val: A,
) -> Result<Option<A>, StmError>;
fn remove(&self, id: A::IdentifierType) -> Option<A>;
fn remove_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
) -> Result<Option<A>, StmError>;
// Provided methods
fn insert(&self, id: A::IdentifierType, val: A) { ... }
fn insert_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
val: A,
) -> Result<(), StmError> { ... }
}
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.
Required Methods§
Sourcefn set(&self, id: A::IdentifierType, val: A)
fn set(&self, id: A::IdentifierType, val: A)
Setter
Set the value of an element at a given index. This operation is not affected by the initial state of the edited entry.
§Arguments
index: A::IdentifierType
– Cell index.val: A
– Attribute value.
§Panics
The method:
- should panic if the index lands out of bounds
- may panic if the index cannot be converted to
usize
Sourcefn set_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
val: A,
) -> Result<(), StmError>
fn set_transac( &self, trans: &mut Transaction, id: A::IdentifierType, val: A, ) -> Result<(), StmError>
Transactional set
§Result / Errors
This method is meant to be called in a context where the returned Result
is used to
validate the transacction passed as argument. The result should not be processed manually.
Sourcefn get(&self, id: A::IdentifierType) -> Option<A>
fn get(&self, id: A::IdentifierType) -> Option<A>
Getter
§Arguments
index: A::IdentifierType
– Cell index.
§Return
The method should return:
Some(val: A)
if there is an attribute associated with the specified index,None
if there is not.
§Panics
The method:
- should panic if the index lands out of bounds
- may panic if the index cannot be converted to
usize
Sourcefn get_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
) -> Result<Option<A>, StmError>
fn get_transac( &self, trans: &mut Transaction, id: A::IdentifierType, ) -> Result<Option<A>, StmError>
Transactional get
§Result / Errors
This method is meant to be called in a context where the returned Result
is used to
validate the transacction passed as argument. The result should not be processed manually.
Sourcefn replace(&self, id: A::IdentifierType, val: A) -> Option<A>
fn replace(&self, id: A::IdentifierType, val: A) -> Option<A>
Setter
Replace the value of an element at a given index.
§Arguments
index: A::IdentifierType
– Cell index.val: A
– Attribute value.
§Return
The method should return:
Some(val_old: A)
if there was an attribute associated with the specified index,None
if there is not.
In both cases, the new value should be set to the one specified as argument.
§Panics
The method:
- should panic if the index lands out of bounds
- may panic if the index cannot be converted to
usize
Sourcefn replace_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
val: A,
) -> Result<Option<A>, StmError>
fn replace_transac( &self, trans: &mut Transaction, id: A::IdentifierType, val: A, ) -> Result<Option<A>, StmError>
Transactional replace
§Result / Errors
This method is meant to be called in a context where the returned Result
is used to
validate the transacction passed as argument. The result should not be processed manually.
Sourcefn remove(&self, id: A::IdentifierType) -> Option<A>
fn remove(&self, id: A::IdentifierType) -> Option<A>
Remove an item from the storage and return it
§Arguments
index: A::IdentifierType
– Cell index.
§Return
The method should return:
Some(val: A)
if there was an attribute associated with the specified index,None
if there is not.
§Panics
The method:
- should panic if the index lands out of bounds
- may panic if the index cannot be converted to
usize
Sourcefn remove_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
) -> Result<Option<A>, StmError>
fn remove_transac( &self, trans: &mut Transaction, id: A::IdentifierType, ) -> Result<Option<A>, StmError>
Transactional remove
§Result / Errors
This method is meant to be called in a context where the returned Result
is used to
validate the transacction passed as argument. The result should not be processed manually.
Provided Methods§
Sourcefn insert(&self, id: A::IdentifierType, val: A)
fn insert(&self, id: A::IdentifierType, val: A)
Setter
Insert a value at a given empty index. Otherwise, see [#Panics] section for more information.
§Arguments
index: A::IdentifierType
– Cell index.val: A
– Attribute value.
§Panics
The method:
- should panic if there is already a value associated to the specified index
- should panic if the index lands out of bounds
- may panic if the index cannot be converted to
usize
Sourcefn insert_transac(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
val: A,
) -> Result<(), StmError>
fn insert_transac( &self, trans: &mut Transaction, id: A::IdentifierType, val: A, ) -> Result<(), StmError>
Transactional insert
§Result / Errors
This method is meant to be called in a context where the returned Result
is used to
validate the transacction passed as argument. The result should not be processed manually.