[−][src]Trait abi_stable::abi_stability::extra_checks::ExtraChecks
Allows defining extra checks for a type.
Look at the module level documentation for more details.
Required methods
fn type_layout(&self) -> &'static TypeLayout
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 UTypeId
s to check compatibility of trait objects
from different dynamic libraries,
because UTypeId
s from different dynamic libraries are incompatible.
fn check_compatibility(
&self,
layout_containing_self: &'static TypeLayout,
layout_containing_other: &'static TypeLayout,
checker: TypeCheckerMut
) -> RResult<(), ExtraChecksError>
&self,
layout_containing_self: &'static TypeLayout,
layout_containing_other: &'static TypeLayout,
checker: TypeCheckerMut
) -> RResult<(), ExtraChecksError>
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 containing self
in the extra_checks field.
layout_containing_other
:
The TypeLayout containing the other ExtraChecks trait object in the extra_checks field,
that this is compared to.
checker
:
The trait object of the type checker,which allows this function to check type layouts.
fn nested_type_layouts<'_self>(
&'_self self
) -> RCow<'_self, [&'static TypeLayout]>
&'_self self
) -> RCow<'_self, [&'static TypeLayout]>
Returns the TypeLayout
s owned or referenced by self
.
This is necessary for the Debug implementation of TypeLayout
.
Provided methods
fn combine(
&self,
_other: ExtraChecksRef,
_checker: TypeCheckerMut
) -> RResult<ROption<ExtraChecksBox>, ExtraChecksError>
&self,
_other: ExtraChecksRef,
_checker: TypeCheckerMut
) -> RResult<ROption<ExtraChecksBox>, ExtraChecksError>
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)
: Ifself
doesn't need to be unified across all dynamic libraries, or the representative version doesn't need to be updated. -
ROk(RSome(_))
: Ifself
needs to be unified across all dynamic libraries, returning the combinedself
andother
. -
RErr(_)
: If there was a problem unifyingself
andother
.
Implementors
impl ExtraChecks for EnabledTraits
[src]
fn type_layout(&self) -> &'static TypeLayout
[src]
fn check_compatibility(
&self,
_layout_containing_self: &'static TypeLayout,
layout_containing_other: &'static TypeLayout,
checker: TypeCheckerMut
) -> RResult<(), ExtraChecksError>
[src]
&self,
_layout_containing_self: &'static TypeLayout,
layout_containing_other: &'static TypeLayout,
checker: TypeCheckerMut
) -> RResult<(), ExtraChecksError>
fn nested_type_layouts(&self) -> RCow<[&'static TypeLayout]>
[src]
impl ExtraChecks for Tag
[src]
fn type_layout(&self) -> &'static TypeLayout
[src]
fn check_compatibility(
&self,
_layout_containing_self: &'static TypeLayout,
layout_containing_other: &'static TypeLayout,
checker: TypeCheckerMut
) -> RResult<(), ExtraChecksError>
[src]
&self,
_layout_containing_self: &'static TypeLayout,
layout_containing_other: &'static TypeLayout,
checker: TypeCheckerMut
) -> RResult<(), ExtraChecksError>