Struct listpack::Listpack[][src]

pub struct Listpack { /* fields omitted */ }

Methods

impl Listpack
[src]

Provides a minimal wrapper to Listpack.

Return the number of elements inside the listpack. This function attempts to use the cached value when within range, otherwise a full scan is needed. As a side effect of calling this function, the listpack header could be modified, because if the count is found to be already within the 'numele' header field range, the new value is set.

Return the total number of bytes the listpack is composed of.

Decodes and returns the entry value of the element.

If the function is called against a badly encoded listpack, so that there is no valid way to parse it, the function returns like if there was an integer encoded with value 12345678900000000 + , this may be an hint to understand that something is wrong. To crash in this case is not sensible because of the different requirements of the application using this lib.

Similarly, there is no error returned since the listpack normally can be assumed to be valid, so that would be a very high API cost. However a function in order to check the integrity of the listpack at load time is provided, check is_valid().

Insert, delete or replace the specified element 'ele' of length 'len' at the specified position 'p', with 'p' being a listpack element pointer obtained with first(), last(), index(), next(), prev() or seek().

The element is inserted before, after, or replaces the element pointed by 'p' depending on the 'where' argument, that can be BEFORE, AFTER or REPLACE.

If 'ele' is set to NULL, the function removes the element pointed by 'p' instead of inserting one.

Returns None on out of memory or when the listpack total length would exceed the max allowed size of 2^32-1, otherwise the new pointer to the listpack holding the new element is returned (and the old pointer passed is no longer considered valid)

If 'newp' is not NULL, at the end of a successful call '*newp' will be set to the address of the element just added, so that it will be possible to continue an iteration with next() and prev().

For deletion operations ('ele' set to None) 'newp' is set to the next element, on the right of the deleted one, or to NULL if the deleted element was the last one.

Append the specified element 'ele' of length 'len' at the end of the listpack. It is implemented in terms of insert(), so the return value is the same as insert().

Insert, delete or replace the specified element 'ele' of length 'len' at the specified position 'p', with 'p' being a listpack element pointer obtained with first(), last(), index(), next(), prev() or seek().

The element is inserted before, after, or replaces the element pointed by 'p' depending on the 'where' argument, that can be BEFORE, AFTER or REPLACE.

If 'ele' is set to NULL, the function removes the element pointed by 'p' instead of inserting one.

Returns None on out of memory or when the listpack total length would exceed the max allowed size of 2^32-1, otherwise the new pointer to the listpack holding the new element is returned (and the old pointer passed is no longer considered valid)

If 'newp' is not NULL, at the end of a successful call '*newp' will be set to the address of the element just added, so that it will be possible to continue an iteration with next() and prev().

For deletion operations ('ele' set to None) 'newp' is set to the next element, on the right of the deleted one, or to NULL if the deleted element was the last one.

Append the specified element 'ele' of length 'len' at the end of the listpack. It is implemented in terms of insert(), so the return value is the same as insert().

Insert, delete or replace the specified element 'ele' of length 'len' at the specified position 'p', with 'p' being a listpack element pointer obtained with first(), last(), index(), next(), prev() or seek().

The element is inserted before, after, or replaces the element pointed by 'p' depending on the 'where' argument, that can be BEFORE, AFTER or REPLACE.

If 'ele' is set to NULL, the function removes the element pointed by 'p' instead of inserting one.

Returns None on out of memory or when the listpack total length would exceed the max allowed size of 2^32-1, otherwise the new pointer to the listpack holding the new element is returned (and the old pointer passed is no longer considered valid)

If 'newp' is not NULL, at the end of a successful call '*newp' will be set to the address of the element just added, so that it will be possible to continue an iteration with next() and prev().

For deletion operations ('ele' set to None) 'newp' is set to the next element, on the right of the deleted one, or to NULL if the deleted element was the last one.

Append the specified element 'ele' of length 'len' at the end of the listpack. It is implemented in terms of insert(), so the return value is the same as insert().

Replace the specified element with the specified value

Remove the element pointed by 'p', and return the resulting listpack. If 'newp' is not NULL, the next element pointer (to the right of the deleted one) is returned by reference. If the deleted element was the last one, '*newp' is set to None.

Return a pointer to the first element of the listpack, or None if the listpack has no elements.

Return a pointer to the last element of the listpack, or None if the listpack has no elements.

/* If 'after' points to an element of the listpack, calling next() will return the pointer to the next element (the one on the right), or None if 'after' already pointed to the last element of the listpack. */

If 'p' points to an element of the listpack, calling prev() will return the pointer to the previous element (the one on the left), or None if 'before' already pointed to the first element of the listpack.

Seek the specified element and returns the pointer to the seeked element. Positive indexes specify the zero-based element to seek from the head to the tail, negative indexes specify elements starting from the tail, where -1 means the last element, -2 the penultimate and so forth. If the index is out of range, NULL is returned.

Trait Implementations

impl Drop for Listpack
[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl !Send for Listpack

impl !Sync for Listpack