Trait UnknownAttributeStorage

Source
pub trait UnknownAttributeStorage:
    Any
    + Debug
    + Downcast {
    // Required methods
    fn new(length: usize) -> Self
       where Self: Sized;
    fn extend(&mut self, length: usize);
    fn n_attributes(&self) -> usize;
    fn merge(
        &self,
        trans: &mut Transaction,
        out: DartIdType,
        lhs_inp: DartIdType,
        rhs_inp: DartIdType,
    ) -> TransactionClosureResult<(), AttributeError>;
    fn split(
        &self,
        trans: &mut Transaction,
        lhs_out: DartIdType,
        rhs_out: DartIdType,
        inp: DartIdType,
    ) -> TransactionClosureResult<(), AttributeError>;
}
Expand description

§Generic attribute storage trait

This trait defines attribute-agnostic functions & methods. The documentation describes the expected behavior of each item. “ID” and “index” are used interchangeably.

Required Methods§

Source

fn new(length: usize) -> Self
where Self: Sized,

Constructor

§Arguments
  • length: usize – Initial length/capacity of the storage. It should correspond to the upper bound of IDs used to index the attribute’s values, i.e. the number of darts including the null dart.
§Return

Return a Self instance which yields correct accesses over the ID range 0..length.

Source

fn extend(&mut self, length: usize)

Extend the storage’s length

§Arguments
  • length: usize – length of which the storage should be extended.
Source

fn n_attributes(&self) -> usize

Return the number of stored attributes, i.e. the number of used slots in the storage (not its length).

Source

fn merge( &self, trans: &mut Transaction, out: DartIdType, lhs_inp: DartIdType, rhs_inp: DartIdType, ) -> TransactionClosureResult<(), AttributeError>

Merge attributes to specified index

§Arguments
  • trans: &mut Transaction – Transaction used for synchronization.
  • out: DartIdentifier – Identifier to associate the result with.
  • lhs_inp: DartIdentifier – Identifier of one attribute value to merge.
  • rhs_inp: DartIdentifier – Identifier of the other attribute value to merge.
§Behavior (pseudo-code)
let new_val = match (attributes.remove(lhs_inp), attributes.remove(rhs_inp)) {
    (Some(v1), Some(v2)) => AttributeUpdate::merge(v1, v2),
    (Some(v), None) | (None, Some(v)) => AttributeUpdate::merge_undefined(Some(v)),
    None, None => AttributeUpdate::merge_undefined(None),
}
attributes.set(out, new_val);
§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

fn split( &self, trans: &mut Transaction, lhs_out: DartIdType, rhs_out: DartIdType, inp: DartIdType, ) -> TransactionClosureResult<(), AttributeError>

Split attribute to specified indices

§Arguments
  • trans: &mut Transaction – Transaction used for synchronization.
  • lhs_out: DartIdentifier – Identifier to associate the result with.
  • rhs_out: DartIdentifier – Identifier to associate the result with.
  • inp: DartIdentifier – Identifier of the attribute value to split.
§Behavior pseudo-code
(val_lhs, val_rhs) = AttributeUpdate::split(attributes.remove(inp).unwrap());
attributes[lhs_out] = val_lhs;
attributes[rhs_out] = val_rhs;
§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.

Implementations§

Source§

impl dyn UnknownAttributeStorage

Source

pub fn is<__T: UnknownAttributeStorage>(&self) -> bool

Returns true if the trait object wraps an object of type __T.

Source

pub fn downcast<__T: UnknownAttributeStorage>( self: Box<Self>, ) -> Result<Box<__T>, Box<Self>>

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

Source

pub fn downcast_rc<__T: UnknownAttributeStorage>( self: Rc<Self>, ) -> Result<Rc<__T>, Rc<Self>>

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

Source

pub fn downcast_ref<__T: UnknownAttributeStorage>(&self) -> Option<&__T>

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

Source

pub fn downcast_mut<__T: UnknownAttributeStorage>(&mut self) -> Option<&mut __T>

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Implementors§