pub struct CList<T, const OFFSET: usize>(/* private fields */);Expand description
A typed C linked list with a sentinel head intended for FFI use-cases where a C subsystem manages a linked list that Rust code needs to read. Generally required only for special cases.
A sentinel head CListHead represents the entire linked list and can be used
for iteration over items of type T; it is not associated with a specific item.
The const generic OFFSET specifies the byte offset of the list_head field within
the struct that T wraps.
§Invariants
- The sentinel
CListHeadhas valid non-NULLnext/prevpointers. OFFSETis the byte offset of thelist_headfield within the struct thatTwraps.- All the list’s
list_headnodes have valid non-NULLnext/prevpointers.
Implementations§
Source§impl<T, const OFFSET: usize> CList<T, OFFSET>
impl<T, const OFFSET: usize> CList<T, OFFSET>
Sourcepub unsafe fn from_raw<'a>(ptr: *mut list_head) -> &'a Self
pub unsafe fn from_raw<'a>(ptr: *mut list_head) -> &'a Self
Create a typed CList reference from a raw sentinel list_head pointer.
§Safety
ptrmust be a valid pointer to an initialized sentinellist_head(e.g. viaINIT_LIST_HEAD()), with valid non-NULLnext/prevpointers.ptrmust remain valid for the lifetime'a.- The list and all linked nodes must not be concurrently modified for the lifetime
'a. - The list must contain items where the
list_headfield is at byte offsetOFFSET. Tmust be#[repr(transparent)]over the C struct.
Auto Trait Implementations§
impl<T, const OFFSET: usize> !Freeze for CList<T, OFFSET>
impl<T, const OFFSET: usize> !RefUnwindSafe for CList<T, OFFSET>
impl<T, const OFFSET: usize> Send for CList<T, OFFSET>where
T: Send,
impl<T, const OFFSET: usize> Sync for CList<T, OFFSET>where
T: Sync,
impl<T, const OFFSET: usize> !Unpin for CList<T, OFFSET>
impl<T, const OFFSET: usize> !UnsafeUnpin for CList<T, OFFSET>
impl<T, const OFFSET: usize> UnwindSafe for CList<T, OFFSET>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
Initializes
slot. Read more