pub struct BoundedListNode { /* private fields */ }Expand description
This struct is intended to represent a list node in Inspect, which doesn’t support list natively. Furthermore, it makes sure that the number of items does not exceed |capacity|
Each item in BoundedListNode is represented as a child node with name as index. This
index is always increasing and does not wrap around. For example, if capacity is 3,
then the children names are [0, 1, 2] on first three addition. When a new node is
added, 0 is popped, and the children names are [1, 2, 3].
Implementations§
Source§impl BoundedListNode
impl BoundedListNode
Sourcepub fn new(node: Node, capacity: usize) -> Self
pub fn new(node: Node, capacity: usize) -> Self
Create a new BoundedListNode with capacity 1 or |capacity|, whichever is larger.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity of the BoundedListNode, the maximum number of child nodes.
Sourcepub fn add_entry<F>(&mut self, initialize: F) -> &Node
pub fn add_entry<F>(&mut self, initialize: F) -> &Node
Create a new entry within a list and return a writer that creates properties or children for this entry. The writer does not have to be kept for the created properties and children to be maintained in the list.
If creating new entry exceeds capacity of the list, the oldest entry is evicted.
The initialize function will be used to atomically initialize all children and properties
under the node.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoundedListNode
impl !RefUnwindSafe for BoundedListNode
impl Send for BoundedListNode
impl Sync for BoundedListNode
impl Unpin for BoundedListNode
impl !UnwindSafe for BoundedListNode
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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more