pub unsafe trait ListItem<const ID: u64 = 0>: ListArcSafe<ID> {
// Required methods
unsafe fn view_links(me: *const Self) -> *mut ListLinks<ID>;
unsafe fn view_value(me: *mut ListLinks<ID>) -> *const Self;
unsafe fn prepare_to_insert(me: *const Self) -> *mut ListLinks<ID>;
unsafe fn post_remove(me: *mut ListLinks<ID>) -> *const Self;
}
Expand description
Implemented by types where a ListArc<Self>
can be inserted into a List
.
§Safety
Implementers must ensure that they provide the guarantees documented on methods provided by this trait.
Required Methods§
sourceunsafe fn view_links(me: *const Self) -> *mut ListLinks<ID>
unsafe fn view_links(me: *const Self) -> *mut ListLinks<ID>
Views the ListLinks
for this value.
§Guarantees
If there is a previous call to prepare_to_insert
and there is no call to post_remove
since the most recent such call, then this returns the same pointer as the one returned by
the most recent call to prepare_to_insert
.
Otherwise, the returned pointer points at a read-only ListLinks
with two null pointers.
§Safety
The provided pointer must point at a valid value. (It need not be in an Arc
.)
sourceunsafe fn view_value(me: *mut ListLinks<ID>) -> *const Self
unsafe fn view_value(me: *mut ListLinks<ID>) -> *const Self
View the full value given its ListLinks
field.
Can only be used when the value is in a list.
§Guarantees
- Returns the same pointer as the one passed to the most recent call to
prepare_to_insert
. - The returned pointer is valid until the next call to
post_remove
.
§Safety
- The provided pointer must originate from the most recent call to
prepare_to_insert
, or from a call toview_links
that happened after the most recent call toprepare_to_insert
. - Since the most recent call to
prepare_to_insert
, thepost_remove
method must not have been called.
sourceunsafe fn prepare_to_insert(me: *const Self) -> *mut ListLinks<ID>
unsafe fn prepare_to_insert(me: *const Self) -> *mut ListLinks<ID>
This is called when an item is inserted into a List
.
§Guarantees
The caller is granted exclusive access to the returned ListLinks
until post_remove
is
called.
§Safety
- The provided pointer must point at a valid value in an
Arc
. - Calls to
prepare_to_insert
andpost_remove
on the same value must alternate. - The caller must own the
ListArc
for this value. - The caller must not give up ownership of the
ListArc
unlesspost_remove
has been called after this call toprepare_to_insert
.