pub struct AttrStorageManager { /* private fields */ }
Expand description
Main attribute storage structure.
This structure is used to store all generic attributes that the user may add to the combinatorial map he’s building.
§Implementation
The structure uses hashmaps in order to store each attribute’s dedicated storage. Which storage
is used is determined by the associated type AttributeBind::StorageType
.
The key type used by the map is each attribute’s TypeId
. This implies that all attributes
must have a different (unique) type. For example, two decimal-valued attribute will need to be
wrapped in different dedicated structures.
Using the TypeId
as the key value for collections yields a cleaner API, where the only
argument passed to access methods is the ID of the cell of which they want the attribute. The
actual attribute type is specified by passing a generic to the method. This bypasses any issues
linked to literal-typed keys, such as typos, naming conventions, portability, etc.
Generics passed in access methods also have a secondary usage. To store heterogeneous
collections, the internal hashmaps uses Box<dyn UnknownAttributeStorage>
as their value type.
Some operations require us to downcast the stored object (implementing
UnknownAttributeStorage
) to the correct collection type. This is achieved by using the
downcast-rs
crate and the associated storage type AttributeBind::StorageType
. What
follows is a simplified version of that code:
pub struct Manager {
inner: HashMap<TypeId, Box<dyn UnknownAttributeStorage>>,
}
impl Manager {
pub fn add_storage<A: AttributeBind + 'static>(
&mut self,
size: usize,
) {
let typeid = TypeId::of::<A>();
let new_storage = <A as AttributeBind>::StorageType::new(size);
self.inner.insert(typeid, Box::new(new_storage));
}
pub fn get_storage<A: AttributeBind>(&self) -> &<A as AttributeBind>::StorageType {
let probably_storage = &self.inner[&TypeId::of::<A>()];
// downcast is possible because:
// - StorageType: AttributeStorage<A>
// - AttributeStorage<A>: UnknownAttributeStorage
probably_storage
.downcast_ref::<<A as AttributeBind>::StorageType>()
.expect("E: could not downcast generic storage to specified attribute type")
}
}
Implementations§
Source§impl AttrStorageManager
impl AttrStorageManager
General methods
Sourcepub fn extend_storages(&mut self, length: usize)
pub fn extend_storages(&mut self, length: usize)
Extend the size of all storages in the manager.
§Arguments
length: usize
– Length by which storages should be extended.
Sourcepub fn add_storage<A: AttributeBind + 'static>(&mut self, size: usize)
pub fn add_storage<A: AttributeBind + 'static>(&mut self, size: usize)
Add a new storage to the manager.
For a breakdown of the principles used for implementation, refer to the Explanation
section of the AttrStorageManager
documentation entry.
§Arguments
size: usize
– Initial size of the new storage.
§Generic
A: AttributeBind + 'static
– Type of the attribute that will be stored.
§Panics
This function will panic if there is already a storage of attribute A
in the manager.
Sourcepub fn extend_storage<A: AttributeBind>(&mut self, length: usize)
pub fn extend_storage<A: AttributeBind>(&mut self, length: usize)
Sourcepub fn get_storage<A: AttributeBind>(
&self,
) -> Option<&<A as AttributeBind>::StorageType>
pub fn get_storage<A: AttributeBind>( &self, ) -> Option<&<A as AttributeBind>::StorageType>
Get a reference to the storage of a given attribute.
§Generic
A: AttributeBind
– Attribute stored by the fetched storage.
§Panics
This method may panic if:
- there’s no storage associated with the specified attribute
- downcasting
Box<dyn UnknownAttributeStorage>
to<A as AttributeBind>::StorageType
fails
Sourcepub fn remove_storage<A: AttributeBind>(&mut self)
pub fn remove_storage<A: AttributeBind>(&mut self)
Remove an entire attribute storage from the manager.
This method is useful when implementing routines that uses attributes to run; Those can then be removed before the final result is returned.
§Generic
A: AttributeBind
– Attribute stored by the fetched storage.
Source§impl AttrStorageManager
impl AttrStorageManager
Merge variants.
Sourcepub fn force_merge_attributes(
&self,
orbit_policy: &OrbitPolicy,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
)
pub fn force_merge_attributes( &self, orbit_policy: &OrbitPolicy, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, )
Execute a merging operation on all attributes associated with a given orbit for specified cells.
This variant is equivalent to merge_attributes
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn force_merge_vertex_attributes(
&self,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
)
pub fn force_merge_vertex_attributes( &self, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, )
Execute a merging operation on all attributes associated with vertices for specified cells.
This variant is equivalent to merge_vertex_attributes
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn force_merge_edge_attributes(
&self,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
)
pub fn force_merge_edge_attributes( &self, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, )
Execute a merging operation on all attributes associated with edges for specified cells.
This variant is equivalent to merge_edge_attributes
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn force_merge_face_attributes(
&self,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
)
pub fn force_merge_face_attributes( &self, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, )
Execute a merging operation on all attributes associated with faces for specified cells.
This variant is equivalent to merge_face_attributes
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn merge_attributes(
&self,
trans: &mut Transaction,
orbit_policy: &OrbitPolicy,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> StmResult<()>
pub fn merge_attributes( &self, trans: &mut Transaction, orbit_policy: &OrbitPolicy, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> StmResult<()>
Execute a merging operation on all attributes associated with a given orbit for specified cells.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.orbit_policy: OrbitPolicy
– Orbit associated with affected attributes.id_out: DartIdentifier
– Identifier to write the result to.id_in_lhs: DartIdentifier
– Identifier of one attribute value to merge.id_in_rhs: DartIdentifier
– Identifier of the other attribute value to merge.
§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.
Sourcepub fn merge_vertex_attributes(
&self,
trans: &mut Transaction,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> StmResult<()>
pub fn merge_vertex_attributes( &self, trans: &mut Transaction, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> StmResult<()>
Execute a merging operation on all attributes associated with vertices for specified cells.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.id_out: DartIdentifier
– Identifier to write the result to.id_in_lhs: DartIdentifier
– Identifier of one attribute value to merge.id_in_rhs: DartIdentifier
– Identifier of the other attribute value to merge.
§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.
Sourcepub fn merge_edge_attributes(
&self,
trans: &mut Transaction,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> StmResult<()>
pub fn merge_edge_attributes( &self, trans: &mut Transaction, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> StmResult<()>
Execute a merging operation on all attributes associated with edges for specified cells.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.id_out: DartIdentifier
– Identifier to write the result to.id_in_lhs: DartIdentifier
– Identifier of one attribute value to merge.id_in_rhs: DartIdentifier
– Identifier of the other attribute value to merge.
§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.
Sourcepub fn merge_face_attributes(
&self,
trans: &mut Transaction,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> StmResult<()>
pub fn merge_face_attributes( &self, trans: &mut Transaction, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> StmResult<()>
Execute a merging operation on all attributes associated with faces for specified cells.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.id_out: DartIdentifier
– Identifier to write the result to.id_in_lhs: DartIdentifier
– Identifier of one attribute value to merge.id_in_rhs: DartIdentifier
– Identifier of the other attribute value to merge.
§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.
Sourcepub fn try_merge_attributes(
&self,
trans: &mut Transaction,
orbit_policy: &OrbitPolicy,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> CMapResult<()>
pub fn try_merge_attributes( &self, trans: &mut Transaction, orbit_policy: &OrbitPolicy, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> CMapResult<()>
Execute a merging operation on all attributes associated with a given orbit for specified cells.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- a merge fails (e.g. because one merging value is missing)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Sourcepub fn try_merge_vertex_attributes(
&self,
trans: &mut Transaction,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> CMapResult<()>
pub fn try_merge_vertex_attributes( &self, trans: &mut Transaction, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> CMapResult<()>
Execute a merging operation on all attributes associated with vertices for specified cells.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- a merge fails (e.g. because one merging value is missing)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Sourcepub fn try_merge_edge_attributes(
&self,
trans: &mut Transaction,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> CMapResult<()>
pub fn try_merge_edge_attributes( &self, trans: &mut Transaction, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> CMapResult<()>
Execute a merging operation on all attributes associated with edges for specified cells.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- a merge fails (e.g. because one merging value is missing)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Sourcepub fn try_merge_face_attributes(
&self,
trans: &mut Transaction,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> CMapResult<()>
pub fn try_merge_face_attributes( &self, trans: &mut Transaction, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> CMapResult<()>
Execute a merging operation on all attributes associated with faces for specified cells.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- a merge fails (e.g. because one merging value is missing)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Sourcepub fn force_merge_attribute<A: AttributeBind>(
&self,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
)
pub fn force_merge_attribute<A: AttributeBind>( &self, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, )
Merge given attribute values.
This variant is equivalent to merge_attribute
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn merge_attribute<A: AttributeBind + AttributeUpdate>(
&self,
trans: &mut Transaction,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> StmResult<()>
pub fn merge_attribute<A: AttributeBind + AttributeUpdate>( &self, trans: &mut Transaction, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> StmResult<()>
Merge given attribute values.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.id_out: DartIdentifier
– Identifier to write the result to.id_in_lhs: DartIdentifier
– Identifier of one attribute value to merge.id_in_rhs: DartIdentifier
– Identifier of the other attribute value to merge.
§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.
Sourcepub fn try_merge_attribute<A: AttributeBind + AttributeUpdate>(
&self,
trans: &mut Transaction,
id_out: DartIdType,
id_in_lhs: DartIdType,
id_in_rhs: DartIdType,
) -> CMapResult<()>
pub fn try_merge_attribute<A: AttributeBind + AttributeUpdate>( &self, trans: &mut Transaction, id_out: DartIdType, id_in_lhs: DartIdType, id_in_rhs: DartIdType, ) -> CMapResult<()>
Merge given attribute values.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- the merge fails (e.g. because one merging value is missing)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Source§impl AttrStorageManager
impl AttrStorageManager
Split variants.
Sourcepub fn force_split_attributes(
&self,
orbit_policy: &OrbitPolicy,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
)
pub fn force_split_attributes( &self, orbit_policy: &OrbitPolicy, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, )
Execute a splitting operation on all attributes associated with a given orbit for specified cells.
This variant is equivalent to split_attributes
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn force_split_vertex_attributes(
&self,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
)
pub fn force_split_vertex_attributes( &self, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, )
Execute a splitting operation on all attributes associated with vertices for specified cells.
This variant is equivalent to split_vertex_attributes
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn force_split_edge_attributes(
&self,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
)
pub fn force_split_edge_attributes( &self, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, )
Execute a splitting operation on all attributes associated with edges for specified cells.
This variant is equivalent to split_edge_attributes
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn force_split_face_attributes(
&self,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
)
pub fn force_split_face_attributes( &self, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, )
Execute a splitting operation on all attributes associated with faces for specified cells.
This variant is equivalent to split_face_attributes
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn split_attributes(
&self,
trans: &mut Transaction,
orbit_policy: &OrbitPolicy,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> StmResult<()>
pub fn split_attributes( &self, trans: &mut Transaction, orbit_policy: &OrbitPolicy, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> StmResult<()>
Execute a splitting operation on all attributes associated with a given orbit for specified cells.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.orbit_policy: OrbitPolicy
– Orbit associated with affected attributes.id_out_lhs: DartIdentifier
– Identifier to write the result to.id_out_rhs: DartIdentifier
– Identifier to write the result to.id_in: DartIdentifier
– Identifier of the attribute value to split.
§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.
Sourcepub fn split_vertex_attributes(
&self,
trans: &mut Transaction,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> StmResult<()>
pub fn split_vertex_attributes( &self, trans: &mut Transaction, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> StmResult<()>
Execute a splitting operation on all attributes associated with vertices for specified cells.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.id_out_lhs: DartIdentifier
– Identifier to write the result to.id_out_rhs: DartIdentifier
– Identifier to write the result to.id_in: DartIdentifier
– Identifier of the attribute value to split.
§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.
Sourcepub fn split_edge_attributes(
&self,
trans: &mut Transaction,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> StmResult<()>
pub fn split_edge_attributes( &self, trans: &mut Transaction, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> StmResult<()>
Execute a splitting operation on all attributes associated with edges for specified cells.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.id_out_lhs: DartIdentifier
– Identifier to write the result to.id_out_rhs: DartIdentifier
– Identifier to write the result to.id_in: DartIdentifier
– Identifier of the attribute value to split.
§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.
Sourcepub fn split_face_attributes(
&self,
trans: &mut Transaction,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> StmResult<()>
pub fn split_face_attributes( &self, trans: &mut Transaction, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> StmResult<()>
Execute a splitting operation on all attributes associated with faces for specified cells.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.id_out_lhs: DartIdentifier
– Identifier to write the result to.id_out_rhs: DartIdentifier
– Identifier to write the result to.id_in: DartIdentifier
– Identifier of the attribute value to split.
§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.
Sourcepub fn try_split_attributes(
&self,
trans: &mut Transaction,
orbit_policy: &OrbitPolicy,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> CMapResult<()>
pub fn try_split_attributes( &self, trans: &mut Transaction, orbit_policy: &OrbitPolicy, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> CMapResult<()>
Execute a splitting operation on all attributes associated with a given orbit for specified cells.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- a split fails (e.g. because there is no value to split from)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Sourcepub fn try_split_vertex_attributes(
&self,
trans: &mut Transaction,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> CMapResult<()>
pub fn try_split_vertex_attributes( &self, trans: &mut Transaction, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> CMapResult<()>
Execute a splitting operation on all attributes associated with vertices for specified cells.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- a split fails (e.g. because there is no value to split from)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Sourcepub fn try_split_edge_attributes(
&self,
trans: &mut Transaction,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> CMapResult<()>
pub fn try_split_edge_attributes( &self, trans: &mut Transaction, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> CMapResult<()>
Execute a splitting operation on all attributes associated with edges for specified cells.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- a split fails (e.g. because there is no value to split from)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Sourcepub fn try_split_face_attributes(
&self,
trans: &mut Transaction,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> CMapResult<()>
pub fn try_split_face_attributes( &self, trans: &mut Transaction, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> CMapResult<()>
Execute a splitting operation on all attributes associated with faces for specified cells.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- a split fails (e.g. because there is no value to split from)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Sourcepub fn force_split_attribute<A: AttributeBind>(
&self,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
)
pub fn force_split_attribute<A: AttributeBind>( &self, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, )
Split given attribute value.
This variant is equivalent to split_attribute
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn split_attribute<A: AttributeBind + AttributeUpdate>(
&self,
trans: &mut Transaction,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> StmResult<()>
pub fn split_attribute<A: AttributeBind + AttributeUpdate>( &self, trans: &mut Transaction, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> StmResult<()>
Split given attribute value.
§Arguments
trans: &mut Transaction
– Transaction used for synchronization.id_out_lhs: DartIdentifier
– Identifier to write the result to.id_out_rhs: DartIdentifier
– Identifier to write the result to.id_in: DartIdentifier
– Identifier of the attribute value to split.
§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.
Sourcepub fn try_split_attribute<A: AttributeBind + AttributeUpdate>(
&self,
trans: &mut Transaction,
id_out_lhs: DartIdType,
id_out_rhs: DartIdType,
id_in: DartIdType,
) -> CMapResult<()>
pub fn try_split_attribute<A: AttributeBind + AttributeUpdate>( &self, trans: &mut Transaction, id_out_lhs: DartIdType, id_out_rhs: DartIdType, id_in: DartIdType, ) -> CMapResult<()>
Split given attribute value.
§Errors
This method will fail, returning an error, if:
- the transaction cannot be completed
- the split fails (e.g. because there is no value to split from)
The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose, through its transaction control policy, to retry or abort as he wishes.
Source§impl AttrStorageManager
impl AttrStorageManager
Attribute read & write methods
Sourcepub fn read_attribute<A: AttributeBind>(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
) -> StmResult<Option<A>>
pub fn read_attribute<A: AttributeBind>( &self, trans: &mut Transaction, id: A::IdentifierType, ) -> StmResult<Option<A>>
Get the value of an attribute.
§Arguments
id: A::IdentifierType
– Cell ID to which the attribute is associated.
§Generic
A: AttributeBind
– Type of the attribute fetched.
§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
This method may panic if:
- there’s no storage associated with the specified attribute
- downcasting
Box<dyn UnknownAttributeStorage>
to<A as AttributeBind>::StorageType
fails - the index lands out of bounds
Sourcepub fn write_attribute<A: AttributeBind>(
&self,
trans: &mut Transaction,
id: A::IdentifierType,
val: A,
) -> StmResult<Option<A>>
pub fn write_attribute<A: AttributeBind>( &self, trans: &mut Transaction, id: A::IdentifierType, val: A, ) -> StmResult<Option<A>>
Set the value of an attribute, and return the old one.
§Arguments
id: A::IdentifierType
– ID of the cell to which the attribute is associated.val: A
– New value of the attribute for the given ID.
§Generic
A: AttributeBind
– Type of the attribute being set.
§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
This method may panic if:
- there’s no storage associated with the specified attribute
- downcasting
Box<dyn UnknownAttributeStorage>
to<A as AttributeBind>::StorageType
fails - the index lands out of bounds
Sourcepub fn force_read_attribute<A: AttributeBind>(
&self,
id: A::IdentifierType,
) -> Option<A>
pub fn force_read_attribute<A: AttributeBind>( &self, id: A::IdentifierType, ) -> Option<A>
Get the value of an attribute.
This variant is equivalent to read_attribute
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn force_write_attribute<A: AttributeBind>(
&self,
id: A::IdentifierType,
val: A,
) -> Option<A>
pub fn force_write_attribute<A: AttributeBind>( &self, id: A::IdentifierType, val: A, ) -> Option<A>
Set the value of an attribute, and return the old one.
This variant is equivalent to write_attribute
, but internally uses a transaction
that will be retried until validated.
Sourcepub fn force_remove_attribute<A: AttributeBind>(
&self,
id: A::IdentifierType,
) -> Option<A>
pub fn force_remove_attribute<A: AttributeBind>( &self, id: A::IdentifierType, ) -> Option<A>
Remove the an item from an attribute storage, and return it.
This variant is equivalent to remove_attribute
, but internally uses a transaction
that will be retried until validated.
Trait Implementations§
Source§impl Default for AttrStorageManager
impl Default for AttrStorageManager
Source§fn default() -> AttrStorageManager
fn default() -> AttrStorageManager
impl Send for AttrStorageManager
impl Sync for AttrStorageManager
Auto Trait Implementations§
impl Freeze for AttrStorageManager
impl !RefUnwindSafe for AttrStorageManager
impl Unpin for AttrStorageManager
impl !UnwindSafe for AttrStorageManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.