Trait AttributeUpdate

Source
pub trait AttributeUpdate:
    Sized
    + Send
    + Sync
    + Clone
    + Copy {
    // Required methods
    fn merge(attr1: Self, attr2: Self) -> Result<Self, AttributeError>;
    fn split(attr: Self) -> Result<(Self, Self), AttributeError>;

    // Provided methods
    fn merge_incomplete(_: Self) -> Result<Self, AttributeError> { ... }
    fn merge_from_none() -> Result<Self, AttributeError> { ... }
    fn split_from_none() -> Result<(Self, Self), AttributeError> { ... }
}
Expand description

§Generic attribute trait

This trait is used to describe how a values of a given attribute are merged and split during sewing and unsewing operations.

§Example

A detailed example is provided in the user guide.

Required Methods§

Source

fn merge(attr1: Self, attr2: Self) -> Result<Self, AttributeError>

Merging routine, i.e. how to obtain a new value from two existing ones.

§Errors

You may use AttributeError::FailedMerge to model a possible failure in your attribute mergin process.

Source

fn split(attr: Self) -> Result<(Self, Self), AttributeError>

Splitting routine, i.e. how to obtain the two new values from a single one.

§Errors

You may use AttributeError::FailedSplit to model a possible failure in your attribute mergin process.

Provided Methods§

Source

fn merge_incomplete(_: Self) -> Result<Self, AttributeError>

Fallback merging routine, i.e. how to obtain a new value from a single existing one.

The returned value directly affects the behavior of sewing methods: For example, if this method returns an error for a given attribute, the sew method will fail. This allows the user to define some attribute-specific behavior and enable fallbacks when it makes sense.

§Return / Errors

The default implementation fails and returns AttributeError::InsufficientData. You may override the implementation and use AttributeError::FailedMerge to model another possible failure.

Source

fn merge_from_none() -> Result<Self, AttributeError>

Fallback merging routine, i.e. how to obtain a new value from no existing one.

The returned value directly affects the behavior of sewing methods: For example, if this method returns an error for a given attribute, the sew method will fail. This allows the user to define some attribute-specific behavior and enable fallbacks when it makes sense.

§Errors

The default implementation fails and returns AttributeError::InsufficientData.

Source

fn split_from_none() -> Result<(Self, Self), AttributeError>

Fallback splitting routine, i.e. how to obtain two new values from no existing one.

The returned value directly affects the behavior of sewing methods: For example, if this method returns an error for a given attribute, the unsew method will fail. This allows the user to define some attribute-specific behavior and enable fallbacks when it makes sense. value).

§Errors

The default implementation fails and returns AttributeError::InsufficientData.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§