Trait containerof::Intrusive
source · pub trait Intrusive: IntrusiveBase {
Show 17 methods
// Required methods
unsafe fn from_alias(ia: IntrusiveAlias) -> Self;
unsafe fn into_alias(self) -> IntrusiveAlias;
fn as_alias_mut(&mut self) -> &mut IntrusiveAlias;
unsafe fn of_alias(ia: &IntrusiveAlias) -> &Self;
unsafe fn of_alias_mut(ia: &mut IntrusiveAlias) -> &mut Self;
fn from_container(c: OwnBox<Self::Container>) -> Self;
fn into_container(self) -> OwnBox<Self::Container>;
fn of_container(c: &Self::Container) -> BorrowBox<'_, Self>;
fn of_container_mut(c: &mut Self::Container) -> BorrowBoxMut<'_, Self>;
fn as_container(&self) -> &Self::Container;
fn as_container_mut(&mut self) -> &mut Self::Container;
unsafe fn from_field(c: OwnBox<Self::Field>) -> Self;
fn into_field(self) -> OwnBox<Self::Field>;
unsafe fn of_field(c: &Self::Field) -> BorrowBox<'_, Self>;
unsafe fn of_field_mut(c: &mut Self::Field) -> BorrowBoxMut<'_, Self>;
fn as_field(&self) -> &Self::Field;
fn as_field_mut(&mut self) -> &mut Self::Field;
}
Expand description
Trait defining routines for translation between containing
structure and intrusive field. The only implementors of this trait
should be the translation-types defined by the
containerof_intrusive!
macro.
Required Methods§
sourceunsafe fn from_alias(ia: IntrusiveAlias) -> Self
unsafe fn from_alias(ia: IntrusiveAlias) -> Self
Ownership-moving translation from generic intrusive pointer alias to type-safe intrusive pointer.
§Safety
This converts a raw pointer to an owned pointer, which is unsafe per Rust’s memory model.
sourceunsafe fn into_alias(self) -> IntrusiveAlias
unsafe fn into_alias(self) -> IntrusiveAlias
Ownership-moving translation from type-safe intrusive pointer to generic intrusive pointer.
§Safety
This converts an owned pointer to a raw pointer, which is unsafe per Rust’s memory model.
sourcefn as_alias_mut(&mut self) -> &mut IntrusiveAlias
fn as_alias_mut(&mut self) -> &mut IntrusiveAlias
Allow using type-safe intrusive pointer as mutable generic intrusive pointer.
sourceunsafe fn of_alias(ia: &IntrusiveAlias) -> &Self
unsafe fn of_alias(ia: &IntrusiveAlias) -> &Self
Allow using generic intrusive pointer as type-safe intrusive pointer.
§Safety
This converts a raw pointer to a borrowed reference, which is unsafe per Rust’s memory model.
sourceunsafe fn of_alias_mut(ia: &mut IntrusiveAlias) -> &mut Self
unsafe fn of_alias_mut(ia: &mut IntrusiveAlias) -> &mut Self
Allow using generic intrusive pointer as mutable type-safe intrusive pointer.
§Safety
This converts a raw pointer to a mutable borrowed reference, which is unsafe per Rust’s memory model.
sourcefn from_container(c: OwnBox<Self::Container>) -> Self
fn from_container(c: OwnBox<Self::Container>) -> Self
Represent ownership of a container as ownership of an Intrusive
pointer type. (Inverse of into_container
.)
sourcefn into_container(self) -> OwnBox<Self::Container>
fn into_container(self) -> OwnBox<Self::Container>
Represent ownership of an Intrusive pointer type as ownership of
its container. (Inverse of from_container
.)
sourcefn of_container(c: &Self::Container) -> BorrowBox<'_, Self>
fn of_container(c: &Self::Container) -> BorrowBox<'_, Self>
Represent a borrow of an intrusive type via a borrow of its container.
sourcefn of_container_mut(c: &mut Self::Container) -> BorrowBoxMut<'_, Self>
fn of_container_mut(c: &mut Self::Container) -> BorrowBoxMut<'_, Self>
Represent a mutable borrow of an intrusive type via a mutable borrow of its container.
sourcefn as_container(&self) -> &Self::Container
fn as_container(&self) -> &Self::Container
Grant referential access to the container of this intrusive pointer type.
sourcefn as_container_mut(&mut self) -> &mut Self::Container
fn as_container_mut(&mut self) -> &mut Self::Container
Grant mutable referential access to the container of this intrusive pointer type.
sourceunsafe fn from_field(c: OwnBox<Self::Field>) -> Self
unsafe fn from_field(c: OwnBox<Self::Field>) -> Self
Assuming the “field” is a field in the container object, take
ownership of the field as an intrusive pointer, allowing
eventual translation back to the container. (Inverse of
into_field
.)
§Safety
The caller must ensure that the OwnBox
argument was
constructed from this type.
sourcefn into_field(self) -> OwnBox<Self::Field>
fn into_field(self) -> OwnBox<Self::Field>
Represent ownership of the container object as ownership of
the intrusive field in the object. (Inverse of from_field
.)
sourceunsafe fn of_field(c: &Self::Field) -> BorrowBox<'_, Self>
unsafe fn of_field(c: &Self::Field) -> BorrowBox<'_, Self>
Represent a borrow of an intrusive type via a borrow of the intrusive field.
§Safety
The caller must ensure that the self::Field
argument was
constructed from this type.
sourceunsafe fn of_field_mut(c: &mut Self::Field) -> BorrowBoxMut<'_, Self>
unsafe fn of_field_mut(c: &mut Self::Field) -> BorrowBoxMut<'_, Self>
Represent a mutable borrow of an intrusive type via a mutable borrow of the intrusive field.
§Safety
The caller must ensure that the self::Field
argument was
constructed from this type.
sourcefn as_field(&self) -> &Self::Field
fn as_field(&self) -> &Self::Field
Grant referential access to the intrusive field represented by this intrusive pointer.
sourcefn as_field_mut(&mut self) -> &mut Self::Field
fn as_field_mut(&mut self) -> &mut Self::Field
Grant mutable referential access to the intrusive field represented by this intrusive pointer.