Trait abi_stable::abi_stability::extra_checks::ExtraChecks[][src]

pub unsafe trait ExtraChecks: Clone + Display + Debug + Send + Sync {
    fn type_layout(&self) -> &'static TypeLayout;
fn check_compatibility(
        &self,
        layout_containing_self: &'static TypeLayout,
        layout_containing_other: &'static TypeLayout,
        checker: TypeCheckerMut<'_>
    ) -> RResult<(), ExtraChecksError>;
fn nested_type_layouts<'_self>(
        &'_self self
    ) -> RCow<'_self, [&'static TypeLayout]>; fn combine(
        &self,
        _other: ExtraChecksRef<'_>,
        _checker: TypeCheckerMut<'_>
    ) -> RResult<ROption<ExtraChecksBox>, ExtraChecksError> { ... } }
Expand description

Allows defining extra checks for a type.

Look at the module level documentation for more details.

Safety

The type_layout method must be defined as <Self as ::abi_stable::StableAbi>::LAYOUT, or equivalent.

All of the methods must be deterministic, always returning the same value with the same arguments.

Required methods

Gets the type layout of Self(the type that implements ExtraChecks)

This is used to downcast the trait object in ForExtraChecksImplementor::downcast_* methods, by ensuring that its type layout is compatible with that of another ExtraChecks trait object

It can’t use UTypeIds to check compatibility of trait objects from different dynamic libraries, because UTypeIds from different dynamic libraries are incompatible.

Checks that self is compatible another type which implements ExtraChecks.

Calling check_layout_compatibility from here will immediately return an error, prefer doing checker.check_compatibility(...) instead.

Parameters

layout_containing_self: The TypeLayout that contains this ExtraChecks trait object in the extra_checks field.

layout_containing_other: The TypeLayout that contains the other ExtraChecks trait object in the extra_checks field, which self is compared to.

checker: The type checker,which allows this function to check type layouts.

Returns the TypeLayouts owned or referenced by self.

This is necessary for the Debug implementation of TypeLayout.

Provided methods

Combines this ExtraChecks trait object with another one.

To guarantee that the extra_checks associated with a type (inside <TheType as StableAbi>::LAYOUT.extra_cheks ) has a single representative value across all dynamic libraries, you must override this method, and return ROk(RSome(_)) by combining self and other in some way.

Parameters

other: The other ExtraChecks trait object that this is combined with..

checker: The trait object of the type checker,which allows this function to check type layouts.

Return value

This returns:

  • ROk(RNone): If self doesn’t need to be unified across all dynamic libraries, or the representative version doesn’t need to be updated.

  • ROk(RSome(_)): If self needs to be unified across all dynamic libraries, returning the combined self and other.

  • RErr(_): If there was a problem unifying self and other.

Implementors