Trait intrusive_collections::Adaptor
[−]
[src]
pub unsafe trait Adaptor<Link> { type Container: ?Sized; unsafe fn get_container(&self, link: *const Link) -> *const Self::Container; unsafe fn get_link(&self, container: *const Self::Container) -> *const Link; }
Trait representing a mapping between an object and an intrusive link type which is a member of that object.
A single object type may have multiple adaptors, which allows it to be part of multiple intrusive collections simultaneously.
In most cases you do not need to implement this trait manually: the
intrusive_adaptor!
macro will generate the necessary implementation for a
given object and link field. However it is possible to implement it manually
if the intrusive link is not a direct field of the object, or if you want
to create an adaptor with generic and/or lifetime parameters.
It is also possible to create stateful adaptors. This allows links and containers to be separated and avoids the need for objects to be modified to contain a link.
Safety
It must be possible to get back a reference to the container by passing a
pointer returned by get_link
to get_container
or get_container_mut
.
Associated Types
Required Methods
unsafe fn get_container(&self, link: *const Link) -> *const Self::Container
Gets a reference to the containing object from a reference to a link.
unsafe fn get_link(&self, container: *const Self::Container) -> *const Link
Gets a reference to the link for the given container object.