#[doc(hidden)]pub unsafe trait ProjectField<Field, I, const VARIANT_ID: i128, const FIELD_ID: i128>: HasField<Field, VARIANT_ID, FIELD_ID>where
I: Invariants,{
type Invariants: Invariants<Aliasing = I::Aliasing>;
type Error;
// Required method
fn only_derive_is_allowed_to_implement_this_trait()
where Self: Sized;
// Provided method
fn is_projectable<'a>(
_ptr: Ptr<'a, Self::Tag, I>,
) -> Result<(), Self::Error> { ... }
}Expand description
Projects a given field from Self.
Implementations of this trait encode the conditions under which a field can
be projected from a Ptr<'_, Self, I>, and how the invariants of that
[Ptr] (I) determine the invariants of pointers projected from it. In
other words, it is a type-level function over invariants; I goes in,
Self::Invariants comes out.
§Safety
T: ProjectField<Field, I, VARIANT_ID, FIELD_ID> if, for a
ptr: Ptr<'_, T, I> such that T::is_projectable(ptr).is_ok(),
<T as HasField<Field, VARIANT_ID, FIELD_ID>>::project(ptr.as_inner())
conforms to T::Invariants.
Required Associated Types§
Sourcetype Invariants: Invariants<Aliasing = I::Aliasing>
type Invariants: Invariants<Aliasing = I::Aliasing>
The invariants of the projected field pointer, with respect to the
invariants, I, of the containing pointer. The aliasing dimension of
the invariants is guaranteed to remain unchanged.
Sourcetype Error
type Error
The failure mode of projection. () if the projection is fallible,
otherwise core::convert::Infallible.
Required Methods§
fn only_derive_is_allowed_to_implement_this_trait()where
Self: Sized,
Provided Methods§
Sourcefn is_projectable<'a>(_ptr: Ptr<'a, Self::Tag, I>) -> Result<(), Self::Error>
fn is_projectable<'a>(_ptr: Ptr<'a, Self::Tag, I>) -> Result<(), Self::Error>
Is the given field projectable from ptr?
If a field with Self::Invariants is projectable from the referent,
this function produces an Ok(ptr) from which the projection can be
made; otherwise Err.
This method must be overriden if the field’s projectability depends on
the value of the bytes in ptr.
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.