honeycomb_core::attributes

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, out: DartIdType, lhs_inp: DartIdType, rhs_inp: DartIdType);
    fn merge_transac(
        &self,
        trans: &mut Transaction,
        out: DartIdType,
        lhs_inp: DartIdType,
        rhs_inp: DartIdType,
    ) -> Result<(), StmError>;
    fn split(&self, lhs_out: DartIdType, rhs_out: DartIdType, inp: DartIdType);
    fn split_transac(
        &self,
        trans: &mut Transaction,
        lhs_out: DartIdType,
        rhs_out: DartIdType,
        inp: DartIdType,
    ) -> Result<(), StmError>;
}
Expand description

Common trait implemented by generic attribute storages.

This trait contain attribute-agnostic function & methods.

The documentation of this trait describe the behavior each function & method should have.

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, out: DartIdType, lhs_inp: DartIdType, rhs_inp: DartIdType)

Merge attributes at specified index

This method should serve as a wire to either AttributeUpdate::merge or AttributeUpdate::merge_undefined after removing the values we wish to merge from the storage.

§Arguments
  • 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);
Source

fn merge_transac( &self, trans: &mut Transaction, out: DartIdType, lhs_inp: DartIdType, rhs_inp: DartIdType, ) -> Result<(), StmError>

Transactional merge

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

Source

fn split(&self, lhs_out: DartIdType, rhs_out: DartIdType, inp: DartIdType)

Split attribute to specified indices

This method should serve as a wire to AttributeUpdate::split after removing the value we want to split from the storage.

§Arguments
  • 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;
Source

fn split_transac( &self, trans: &mut Transaction, lhs_out: DartIdType, rhs_out: DartIdType, inp: DartIdType, ) -> Result<(), StmError>

Transactional split

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

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§