referrerpolicy=no-referrer-when-downgrade
pallet_migrations

Type Alias RawCursorOf

Source
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>

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>

pub fn new() -> BoundedVec<T, S>

Create Self with no items.

pub fn clear(&mut self)

Exactly the same semantics as Vec::clear.

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)
where F: FnMut(&T, &T) -> Ordering,

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)
where F: FnMut(&T) -> K, K: Ord,

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,

Exactly the same semantics as slice::sort.

This is safe since sorting cannot change the number of elements in the vector.

pub fn remove(&mut self, index: usize) -> T

Exactly the same semantics as Vec::remove.

§Panics

Panics if index is out of bounds.

pub fn swap_remove(&mut self, index: usize) -> T

Exactly the same semantics as slice::swap_remove.

§Panics

Panics if index is out of bounds.

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool,

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]>,

Exactly the same semantics as slice::get_mut.

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>

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>

Exactly the same semantics as slice::iter_mut.

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>,

Exact same semantics as Vec::drain.

§

impl<T, S> BoundedVec<T, S>
where S: Get<u32>,

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>

Allocate self with the maximum possible capacity.

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 bound() -> usize

Get the bound of the type in usize.

pub fn is_full(&self) -> bool

Returns true if this collection is full.

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>

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

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)

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,

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<(), ()>

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<(), ()>

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>>

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>

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_push(&mut self, element: T) -> Result<(), T>

Exactly the same semantics as Vec::push, but returns an Err (and is a noop) if the new length of the vector exceeds S.

§Panics

Panics if the new capacity exceeds isize::MAX bytes.

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<(), ()>

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> AsMut<[T]> for BoundedVec<T, S>

§

fn as_mut(&mut self) -> &mut [T]

Converts this type into a mutable reference of the (usually inferred) input type.
§

impl<T, S> AsRef<[T]> for BoundedVec<T, S>

§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<T, S> AsRef<Vec<T>> for BoundedVec<T, S>

§

fn as_ref(&self) -> &Vec<T>

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<T, S> Clone for BoundedVec<T, S>
where T: Clone,

§

fn clone(&self) -> BoundedVec<T, S>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T, S> Debug for BoundedVec<T, S>
where Vec<T>: Debug, S: Get<u32>,

§

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

Formats the value using the given formatter. Read more
§

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,

Attempt to deserialise the value from input.
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl<T, S> DecodeLength for BoundedVec<T, S>

§

fn len(self_encoded: &[u8]) -> Result<usize, Error>

Return the number of elements in self_encoded.
§

impl<T, S> Default for BoundedVec<T, S>

§

fn default() -> BoundedVec<T, S>

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

impl<T, S> Deref for BoundedVec<T, S>

§

type Target = Vec<T>

The resulting type after dereferencing.
§

fn deref(&self) -> &<BoundedVec<T, S> as Deref>::Target

Dereferences the value.
§

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>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<T, S> Encode for BoundedVec<T, S>
where Vec<T>: Encode, PhantomData<S>: Encode,

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<__CodecOutputEdqy>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
where __CodecOutputEdqy: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl<T, S> Hash for BoundedVec<T, S>
where T: Hash,

§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl<T, S, I> Index<I> for BoundedVec<T, S>
where I: SliceIndex<[T]>,

§

type Output = <I as SliceIndex<[T]>>::Output

The returned type after indexing.
§

fn index(&self, index: I) -> &<BoundedVec<T, S> as Index<I>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<T, S, I> IndexMut<I> for BoundedVec<T, S>
where I: SliceIndex<[T]>,

§

fn index_mut(&mut self, index: I) -> &mut <BoundedVec<T, S> as Index<I>>::Output

Performs the mutable indexing (container[index]) operation. Read more
§

impl<T, S> IntoIterator for BoundedVec<T, S>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> <BoundedVec<T, S> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
§

impl<T, S> JsonSchema for BoundedVec<T, S>
where T: JsonSchema, S: JsonSchema,

§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

impl<T, S> MaxEncodedLen for BoundedVec<T, S>
where T: MaxEncodedLen, S: Get<u32>, BoundedVec<T, S>: Encode,

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl<T, Bound> Ord for BoundedVec<T, Bound>
where T: Ord, Bound: Get<u32>,

§

fn cmp(&self, other: &BoundedVec<T, Bound>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl<'a, T, BoundSelf, BoundRhs> PartialEq<BoundedSlice<'a, T, BoundRhs>> for BoundedVec<T, BoundSelf>
where T: PartialEq, BoundSelf: Get<u32>, BoundRhs: Get<u32>,

§

fn eq(&self, rhs: &BoundedSlice<'a, T, BoundRhs>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T, BoundSelf, BoundRhs> PartialEq<BoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
where T: PartialEq, BoundSelf: Get<u32>, BoundRhs: Get<u32>,

§

fn eq(&self, rhs: &BoundedVec<T, BoundRhs>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T, S> PartialEq<Vec<T>> for BoundedVec<T, S>
where T: PartialEq, S: Get<u32>,

§

fn eq(&self, other: &Vec<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T, BoundSelf, BoundRhs> PartialEq<WeakBoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
where T: PartialEq, BoundSelf: Get<u32>, BoundRhs: Get<u32>,

§

fn eq(&self, rhs: &WeakBoundedVec<T, BoundRhs>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<'a, T, BoundSelf, BoundRhs> PartialOrd<BoundedSlice<'a, T, BoundRhs>> for BoundedVec<T, BoundSelf>
where T: PartialOrd, BoundSelf: Get<u32>, BoundRhs: Get<u32>,

§

fn partial_cmp(&self, other: &BoundedSlice<'a, T, BoundRhs>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl<T, BoundSelf, BoundRhs> PartialOrd<BoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
where T: PartialOrd, BoundSelf: Get<u32>, BoundRhs: Get<u32>,

§

fn partial_cmp(&self, other: &BoundedVec<T, BoundRhs>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl<T, BoundSelf, BoundRhs> PartialOrd<WeakBoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
where T: PartialOrd, BoundSelf: Get<u32>, BoundRhs: Get<u32>,

§

fn partial_cmp(&self, other: &WeakBoundedVec<T, BoundRhs>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl<T, S> Serialize for BoundedVec<T, S>
where T: Serialize,

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl<T, S> StorageDecodeLength for BoundedVec<T, S>

§

fn decode_len(key: &[u8]) -> Option<usize>

Decode the length of the storage value at key. Read more
§

impl<T, S> StorageTryAppend<T> for BoundedVec<T, S>
where S: Get<u32>,

§

fn bound() -> usize

§

impl<T, S> TruncateFrom<Vec<T>> for BoundedVec<T, S>
where S: Get<u32>,

§

fn truncate_from(unbound: Vec<T>) -> BoundedVec<T, S>

Create an object through truncation.
§

impl<I, T, Bound> TryCollect<BoundedVec<T, Bound>> for I
where I: ExactSizeIterator<Item = T> + Iterator, Bound: Get<u32>,

§

type Error = &'static str

The error type that gets returned when a collection can’t be made from self.
§

fn try_collect( self, ) -> Result<BoundedVec<T, Bound>, <I as TryCollect<BoundedVec<T, Bound>>>::Error>

Consume self and try to collect the results into C. Read more
§

impl<T, S> TryFrom<Vec<T>> for BoundedVec<T, S>
where S: Get<u32>,

§

type Error = Vec<T>

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

fn try_from( t: Vec<T>, ) -> Result<BoundedVec<T, S>, <BoundedVec<T, S> as TryFrom<Vec<T>>>::Error>

Performs the conversion.
§

impl<T, S> TypeInfo for BoundedVec<T, S>
where Vec<T>: TypeInfo + 'static, PhantomData<S>: TypeInfo + 'static, T: TypeInfo + 'static, S: 'static,

§

type Identity = BoundedVec<T, S>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl<T, S> DecodeWithMemTracking for BoundedVec<T, S>
where T: DecodeWithMemTracking, S: Get<u32>,

§

impl<T, S> EncodeLike<Vec<T>> for BoundedVec<T, S>
where T: Encode + Decode, S: Get<u32>,

§

impl<T, S> EncodeLike for BoundedVec<T, S>
where Vec<T>: Encode, PhantomData<S>: Encode,

§

impl<T, S> Eq for BoundedVec<T, S>
where S: Get<u32>, T: Eq,