Node

Struct Node 

Source
pub struct Node<T>
where T: ?Sized + Types,
{ /* private fields */ }
Expand description

A node in a PinList.

This type is a state machine between three states:

  1. Initial: The initial state; the node is not registered in any list. This is the only state that can be dropped without aborting the process.
  2. Linked: The node has been linked into a PinList. It holds a Protected and an Unprotected, of which the former can only be accessed when access to the PinList can be proven. Dropping a node in this state will abort.
  3. Removed: The node has been removed from a PinList. It holds a Removed and an Unprotected. Similar to the “linked” state, proof of access to the PinList is required for most operations. Dropping a node in this state will abort.

Implementations§

Source§

impl<T: ?Sized> Node<T>
where <T as ConstFnBounds>::Type: Types,

Source

pub const fn new() -> Self

Create a new node in its initial state.

You can move this node into other states by functions like PinList::push_front.

Source§

impl<T: ?Sized + Types> Node<T>

Source

pub fn is_initial(&self) -> bool

Check whether the node is in its initial state.

Source

pub fn insert_before( self: Pin<&mut Self>, cursor: &mut CursorMut<'_, T>, protected: T::Protected, unprotected: T::Unprotected, ) -> Pin<&mut InitializedNode<'_, T>>

Insert this node into the linked list before the given cursor.

§Panics

Panics if the node is not in its initial state.

Source

pub fn insert_after( self: Pin<&mut Self>, cursor: &mut CursorMut<'_, T>, protected: T::Protected, unprotected: T::Unprotected, ) -> Pin<&mut InitializedNode<'_, T>>

Insert this node into the linked list after the given cursor.

§Panics

Panics if the node is not in its initial state.

Source

pub fn initialized(&self) -> Option<&InitializedNode<'_, T>>

Borrow the node, if it is initialized (linked or removed).

Returns None if the node is in the initial state.

Source

pub fn initialized_mut( self: Pin<&mut Self>, ) -> Option<Pin<&mut InitializedNode<'_, T>>>

Borrow uniquely the node, if it is initialized (linked or removed).

Returns None if the node is in the initial state.

Trait Implementations§

Source§

impl<T: ?Sized + Types> Debug for Node<T>
where T::Unprotected: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized + Types> Default for Node<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Drop for Node<T>
where T: ?Sized + Types,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: ?Sized + Types> Send for Node<T>
where T::Id: Send, T::Protected: Send, T::Removed: Send, T::Unprotected: Send + Sync,

Source§

impl<T: ?Sized + Types> Sync for Node<T>
where T::Id: Sync, T::Unprotected: Sync,

Source§

impl<'__pin, T> Unpin for Node<T>
where PinnedFieldsOf<__Origin<'__pin, T>>: Unpin, T: ?Sized + Types,

Auto Trait Implementations§

§

impl<T> !Freeze for Node<T>

§

impl<T> !RefUnwindSafe for Node<T>

§

impl<T> !UnwindSafe for Node<T>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.