Expand description
Intrusive structure support in Rust.
An intrusive structure is a general-purpose structure directly embedded within a containing structure, in order to add that general-purpose facility to the container. As an example, one might use an intrusive “link” structure to allow objects to be organized in a linked-list:
§Example
struct Link {
next: Option<ContainerLink>,
}
struct List {
head: Option<ContainerLink>,
tail: Option<ContainerLink>,
}
struct Container {
link: Link,
}
containerof_intrusive!(ContainerLink = Container:link::Link);
Macros§
- containerof_
field_ offset - Implement C-like
offsetof
macro in Rust. Rust has stabilized ::std::mem::offset_of! since 1.77.0, you should use that, instead. - containerof_
intrusive - Define a type representing the translation between an intrusive field and its containing structure.
Structs§
- Borrow
Box - A borrow-pointer that does not require explicit ownership of the value being borrowed. Used to allow construction of the Intrusive structure translation type from a borrow pointer.
- Borrow
BoxMut - A mutable borrow-pointer that does not require explicit ownership of the value being borrowed. Used to allow construction of the Intrusive structure translation type from a mutable borrow pointer.
- Intrusive
Alias - Alias that has the same representation as an intrusive translation type. The idea is to be able to use this alias for intrusive facility implementations, by defining the “true” implementation of the facility to use the single (but type-unsafe) IntrusiveAlias type, while allowing type-safe wrapper implementations to delegate their behavior to the implementation function.
- OwnBox
- Represent ownership of an object via ownership of an intrusive
field within the object. Differs from Rust-standard
Box<T>
in that dropping anOwnBox<T>
instance is a bug.
Traits§
- Intrusive
- 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. - Intrusive
Base - Minimal trait that, when implemented for a type, allows for the
blanket implementation of the
Intrusive`` trait for that type. This is the trait implemented by the
containerof_intrusive!macro, and the only implementors of this trait should be the translation-types defined by the
containerof_intrusive!` macro.