pub type RawCursorOf<T> = BoundedVec<u8, <T as Config>::CursorMaxLen>;
Expand description
Convenience alias for the raw inner cursor of a migration.
Aliased Type§
struct RawCursorOf<T>(/* private fields */);
Implementations
§impl<T, S> BoundedVec<T, S>
impl<T, S> BoundedVec<T, S>
pub fn as_bounded_slice(&self) -> BoundedSlice<'_, T, S>
pub fn as_bounded_slice(&self) -> BoundedSlice<'_, T, S>
Return a [BoundedSlice
] with the content and bound of [Self
].
§impl<T, S> BoundedVec<T, S>
impl<T, S> BoundedVec<T, S>
pub fn new() -> BoundedVec<T, S>
pub fn new() -> BoundedVec<T, S>
Create Self
with no items.
pub fn clear(&mut self)
pub fn clear(&mut self)
Exactly the same semantics as Vec::clear
.
pub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Consume self, and return the inner Vec
. Henceforth, the Vec<_>
can be altered in an
arbitrary way. At some point, if the reverse conversion is required, TryFrom<Vec<_>>
can
be used.
This is useful for cases if you need access to an internal API of the inner Vec<_>
which
is not provided by the wrapper BoundedVec
.
pub fn sort_by<F>(&mut self, compare: F)
pub fn sort_by<F>(&mut self, compare: F)
Exactly the same semantics as slice::sort_by
.
This is safe since sorting cannot change the number of elements in the vector.
pub fn sort_by_key<K, F>(&mut self, f: F)
pub fn sort_by_key<K, F>(&mut self, f: F)
Exactly the same semantics as slice::sort_by_key
.
This is safe since sorting cannot change the number of elements in the vector.
pub fn sort(&mut self)where
T: Ord,
pub fn sort(&mut self)where
T: Ord,
Exactly the same semantics as slice::sort
.
This is safe since sorting cannot change the number of elements in the vector.
pub fn swap_remove(&mut self, index: usize) -> T
pub fn swap_remove(&mut self, index: usize) -> T
pub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Exactly the same semantics as Vec::retain
.
pub fn get_mut<I>(
&mut self,
index: I,
) -> Option<&mut <I as SliceIndex<[T]>>::Output>where
I: SliceIndex<[T]>,
pub fn get_mut<I>(
&mut self,
index: I,
) -> Option<&mut <I as SliceIndex<[T]>>::Output>where
I: SliceIndex<[T]>,
Exactly the same semantics as slice::get_mut
.
pub fn truncate(&mut self, s: usize)
pub fn truncate(&mut self, s: usize)
Exactly the same semantics as Vec::truncate
.
This is safe because truncate
can never increase the length of the internal vector.
pub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Exactly the same semantics as Vec::pop
.
This is safe since popping can only shrink the inner vector.
pub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Exactly the same semantics as slice::iter_mut
.
pub fn last_mut(&mut self) -> Option<&mut T>
pub fn last_mut(&mut self) -> Option<&mut T>
Exactly the same semantics as slice::last_mut
.
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>where
R: RangeBounds<usize>,
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>where
R: RangeBounds<usize>,
Exact same semantics as Vec::drain
.
§impl<T, S> BoundedVec<T, S>where
S: Get<u32>,
impl<T, S> BoundedVec<T, S>where
S: Get<u32>,
pub fn with_bounded_capacity(capacity: usize) -> BoundedVec<T, S>
pub fn with_bounded_capacity(capacity: usize) -> BoundedVec<T, S>
Pre-allocate capacity
items in self.
If capacity
is greater than [Self::bound
], then the minimum of the two is used.
pub fn with_max_capacity() -> BoundedVec<T, S>
pub fn with_max_capacity() -> BoundedVec<T, S>
Allocate self with the maximum possible capacity.
pub fn truncate_from(v: Vec<T>) -> BoundedVec<T, S>
pub fn truncate_from(v: Vec<T>) -> BoundedVec<T, S>
Consume and truncate the vector v
in order to create a new instance of Self
from it.
pub fn force_insert_keep_right(
&mut self,
index: usize,
element: T,
) -> Result<Option<T>, T>
pub fn force_insert_keep_right( &mut self, index: usize, element: T, ) -> Result<Option<T>, T>
Forces the insertion of element
into self
retaining all items with index at least
index
.
If index == 0
and self.len() == Self::bound()
, then this is a no-op.
If Self::bound() < index
or self.len() < index
, then this is also a no-op.
Returns Ok(maybe_removed)
if the item was inserted, where maybe_removed
is
Some(removed)
if an item was removed to make room for the new one. Returns Err(element)
if element
cannot be inserted.
pub fn force_insert_keep_left(
&mut self,
index: usize,
element: T,
) -> Result<Option<T>, T>
pub fn force_insert_keep_left( &mut self, index: usize, element: T, ) -> Result<Option<T>, T>
Forces the insertion of element
into self
retaining all items with index at most
index
.
If index == Self::bound()
and self.len() == Self::bound()
, then this is a no-op.
If Self::bound() < index
or self.len() < index
, then this is also a no-op.
Returns Ok(maybe_removed)
if the item was inserted, where maybe_removed
is
Some(removed)
if an item was removed to make room for the new one. Returns Err(element)
if element
cannot be inserted.
pub fn slide(&mut self, index: usize, insert_position: usize) -> bool
pub fn slide(&mut self, index: usize, insert_position: usize) -> bool
Move the position of an item from one location to another in the slice.
Except for the item being moved, the order of the slice remains the same.
index
is the location of the item to be moved.insert_position
is the index of the item in the slice which should immediately follow the item which is being moved.
Returns true
of the operation was successful, otherwise false
if a noop.
pub fn force_push(&mut self, element: T)
pub fn force_push(&mut self, element: T)
Forces the insertion of s
into self
truncating first if necessary.
Infallible, but if the bound is zero, then it’s a no-op.
pub fn bounded_resize(&mut self, size: usize, value: T)where
T: Clone,
pub fn bounded_resize(&mut self, size: usize, value: T)where
T: Clone,
Same as Vec::resize
, but if size
is more than [Self::bound
], then [Self::bound
] is
used.
pub fn try_extend(
&mut self,
with: impl IntoIterator<Item = T> + ExactSizeIterator,
) -> Result<(), ()>
pub fn try_extend( &mut self, with: impl IntoIterator<Item = T> + ExactSizeIterator, ) -> Result<(), ()>
Exactly the same semantics as Vec::extend
, but returns an error and does nothing if the
length of the outcome is larger than the bound.
pub fn try_append(&mut self, other: &mut Vec<T>) -> Result<(), ()>
pub fn try_append(&mut self, other: &mut Vec<T>) -> Result<(), ()>
Exactly the same semantics as Vec::append
, but returns an error and does nothing if the
length of the outcome is larger than the bound.
pub fn try_mutate(
self,
mutate: impl FnMut(&mut Vec<T>),
) -> Option<BoundedVec<T, S>>
pub fn try_mutate( self, mutate: impl FnMut(&mut Vec<T>), ) -> Option<BoundedVec<T, S>>
Consumes self and mutates self via the given mutate
function.
If the outcome of mutation is within bounds, Some(Self)
is returned. Else, None
is
returned.
This is essentially a consuming shorthand [Self::into_inner
] -> ...
->
[Self::try_from
].
pub fn try_insert(&mut self, index: usize, element: T) -> Result<(), T>
pub fn try_insert(&mut self, index: usize, element: T) -> Result<(), T>
Exactly the same semantics as Vec::insert
, but returns an Err
(and is a noop) if the
new length of the vector exceeds S
.
§Panics
Panics if index > len
.
pub fn try_rotate_left(&mut self, mid: usize) -> Result<(), ()>
pub fn try_rotate_left(&mut self, mid: usize) -> Result<(), ()>
Exactly the same semantics as [Vec::rotate_left
], but returns an Err
(and is a noop) if mid
is larger then the current length.
pub fn try_rotate_right(&mut self, mid: usize) -> Result<(), ()>
pub fn try_rotate_right(&mut self, mid: usize) -> Result<(), ()>
Exactly the same semantics as [Vec::rotate_right
], but returns an Err
(and is a noop) if mid
is larger then the current length.
Trait Implementations
§impl<T, S> Decode for BoundedVec<T, S>where
T: Decode,
S: Get<u32>,
impl<T, S> Decode for BoundedVec<T, S>where
T: Decode,
S: Get<u32>,
§fn decode<I>(input: &mut I) -> Result<BoundedVec<T, S>, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<BoundedVec<T, S>, Error>where
I: Input,
§fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
§fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
§impl<T, S> DecodeLength for BoundedVec<T, S>
impl<T, S> DecodeLength for BoundedVec<T, S>
§impl<'de, T, S> Deserialize<'de> for BoundedVec<T, S>where
S: Get<u32>,
T: Deserialize<'de>,
impl<'de, T, S> Deserialize<'de> for BoundedVec<T, S>where
S: Get<u32>,
T: Deserialize<'de>,
§fn deserialize<D>(
deserializer: D,
) -> Result<BoundedVec<T, S>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<BoundedVec<T, S>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<T, S> Encode for BoundedVec<T, S>where
Vec<T>: Encode,
PhantomData<S>: Encode,
impl<T, S> Encode for BoundedVec<T, S>where
Vec<T>: Encode,
PhantomData<S>: Encode,
§fn encode_to<__CodecOutputEdqy>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)where
__CodecOutputEdqy: Output + ?Sized,
fn encode_to<__CodecOutputEdqy>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)where
__CodecOutputEdqy: Output + ?Sized,
§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
§impl<T, S, I> Index<I> for BoundedVec<T, S>where
I: SliceIndex<[T]>,
impl<T, S, I> Index<I> for BoundedVec<T, S>where
I: SliceIndex<[T]>,
§impl<T, S, I> IndexMut<I> for BoundedVec<T, S>where
I: SliceIndex<[T]>,
impl<T, S, I> IndexMut<I> for BoundedVec<T, S>where
I: SliceIndex<[T]>,
§impl<T, S> IntoIterator for BoundedVec<T, S>
impl<T, S> IntoIterator for BoundedVec<T, S>
§impl<T, S> JsonSchema for BoundedVec<T, S>where
T: JsonSchema,
S: JsonSchema,
impl<T, S> JsonSchema for BoundedVec<T, S>where
T: JsonSchema,
S: JsonSchema,
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more