pub struct ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,{ /* private fields */ }
Expand description
A list of items that lives inside a managed buffer.
Items can be either stored there in full (e.g. u32
),
or just via handle (e.g. BigUint<M>
).
Implementations§
Source§impl<M: ManagedTypeApi> ManagedVec<M, EsdtTokenPayment<M>>
impl<M: ManagedTypeApi> ManagedVec<M, EsdtTokenPayment<M>>
Sourcepub fn as_multi_egld_or_esdt_payment(&self) -> &MultiEgldOrEsdtPayment<M>
pub fn as_multi_egld_or_esdt_payment(&self) -> &MultiEgldOrEsdtPayment<M>
Zero-cost conversion that loosens the EGLD restriction.
It is always safe to do, since the 2 types are guaranteed to have the same layout.
Sourcepub fn into_multi_egld_or_esdt_payment(self) -> MultiEgldOrEsdtPayment<M>
pub fn into_multi_egld_or_esdt_payment(self) -> MultiEgldOrEsdtPayment<M>
Zero-cost conversion that loosens the EGLD restriction.
It is always safe to do, since the 2 types are guaranteed to have the same layout.
Source§impl<M, T> ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<M, T> ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
Source§impl<M, T> ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<M, T> ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
pub fn is_empty(&self) -> bool
pub fn try_get(&self, index: usize) -> Option<T::Ref<'_>>
Sourcepub fn to_array_of_refs<const N: usize>(&self) -> Option<[T::Ref<'_>; N]>
pub fn to_array_of_refs<const N: usize>(&self) -> Option<[T::Ref<'_>; N]>
Extracts all elements to an array, if the length matches exactly.
The resulting array contains mere references to the items, as defined in ManagedVecItem
.
Sourcepub fn get(&self, index: usize) -> T::Ref<'_>
pub fn get(&self, index: usize) -> T::Ref<'_>
Retrieves element at index, if the index is valid. Otherwise, signals an error and terminates execution.
Sourcepub fn is_single_item(&self) -> Option<T::Ref<'_>>
pub fn is_single_item(&self) -> Option<T::Ref<'_>>
If it contains precisely one item, will return Some
with a reference to that item.
Will return None
for zero or more than one item.
pub fn get_mut(&mut self, index: usize) -> ManagedVecRefMut<'_, M, T>
pub fn set(&mut self, index: usize, item: T) -> Result<(), InvalidSliceError>
Sourcepub fn slice(&self, start_index: usize, end_index: usize) -> Option<Self>
pub fn slice(&self, start_index: usize, end_index: usize) -> Option<Self>
Returns a new ManagedVec
, containing the [start_index, end_index) range of elements.
Returns None
if any index is out of range
pub fn push(&mut self, item: T)
pub fn remove(&mut self, index: usize)
pub fn take(&mut self, index: usize) -> T
Sourcepub fn from_single_item(item: T) -> Self
pub fn from_single_item(item: T) -> Self
New ManagedVec
instance with 1 element in it.
pub fn overwrite_with_single_item(&mut self, item: T)
Sourcepub fn append_vec(&mut self, item: ManagedVec<M, T>)
pub fn append_vec(&mut self, item: ManagedVec<M, T>)
Appends all the contents of another managed vec at the end of the current one. Consumes the other vec in the process.
pub fn into_vec(self) -> Vec<T>
Sourcepub fn with_self_as_vec<R, F>(&mut self, f: F) -> R
pub fn with_self_as_vec<R, F>(&mut self, f: F) -> R
Temporarily converts self to a Vec<T>
.
All operations performed on the temporary vector get saved back to the underlying buffer.
pub fn iter(&self) -> ManagedVecRefIterator<'_, M, T> ⓘ
Sourcepub fn as_multi(&self) -> &MultiValueManagedVec<M, T>
pub fn as_multi(&self) -> &MultiValueManagedVec<M, T>
Creates a reference to and identical object, but one which behaves like a multi-value-vec.
Source§impl<M, T> ManagedVec<M, T>
impl<M, T> ManagedVec<M, T>
pub fn sort(&mut self)
sort_unstable
instead.pub fn sort_by<F>(&mut self, compare: F)
sort_unstable_by
instead.pub fn sort_by_key<K, F>(&mut self, f: F)
sort_unstable_by_key
instead.pub fn sort_by_cached_key<K, F>(&mut self, f: F)
pub fn sort_unstable(&mut self)
pub fn sort_unstable_by<F>(&mut self, compare: F)
pub fn sort_unstable_by_key<K, F>(&mut self, f: F)
pub fn is_sorted(&self) -> bool
Source§impl<M, T> ManagedVec<M, T>
impl<M, T> ManagedVec<M, T>
Trait Implementations§
Source§impl<M, T> Clone for ManagedVec<M, T>
impl<M, T> Clone for ManagedVec<M, T>
Source§impl<M, T> Debug for ManagedVec<M, T>
impl<M, T> Debug for ManagedVec<M, T>
Source§impl<M, T> Default for ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<M, T> Default for ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
Source§impl<M, V> Extend<V> for ManagedVec<M, V>where
M: ManagedTypeApi,
V: ManagedVecItem,
impl<M, V> Extend<V> for ManagedVec<M, V>where
M: ManagedTypeApi,
V: ManagedVecItem,
Source§fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<M> From<ManagedVec<M, ManagedBuffer<M>>> for ManagedArgBuffer<M>where
M: ManagedTypeApi,
impl<M> From<ManagedVec<M, ManagedBuffer<M>>> for ManagedArgBuffer<M>where
M: ManagedTypeApi,
Source§fn from(data: ManagedVec<M, ManagedBuffer<M>>) -> Self
fn from(data: ManagedVec<M, ManagedBuffer<M>>) -> Self
Source§impl<M, T> From<ManagedVec<M, T>> for MultiValueEncoded<M, T>
impl<M, T> From<ManagedVec<M, T>> for MultiValueEncoded<M, T>
Source§fn from(v: ManagedVec<M, T>) -> Self
fn from(v: ManagedVec<M, T>) -> Self
Source§impl<M, T> From<ManagedVec<M, T>> for MultiValueManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<M, T> From<ManagedVec<M, T>> for MultiValueManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
Source§fn from(managed_vec: ManagedVec<M, T>) -> Self
fn from(managed_vec: ManagedVec<M, T>) -> Self
Source§impl<M, T> From<ManagedVec<M, T>> for MultiValueManagedVecCounted<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<M, T> From<ManagedVec<M, T>> for MultiValueManagedVecCounted<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
Source§fn from(v: ManagedVec<M, T>) -> Self
fn from(v: ManagedVec<M, T>) -> Self
Source§impl<M, T, I> From<Vec<I>> for ManagedVec<M, T>
impl<M, T, I> From<Vec<I>> for ManagedVec<M, T>
Source§impl<M, V> FromIterator<V> for ManagedVec<M, V>where
M: ManagedTypeApi,
V: ManagedVecItem,
impl<M, V> FromIterator<V> for ManagedVec<M, V>where
M: ManagedTypeApi,
V: ManagedVecItem,
Source§fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self
Source§impl<'a, M, T> IntoIterator for &'a ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<'a, M, T> IntoIterator for &'a ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
Source§impl<M, T> IntoIterator for ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<M, T> IntoIterator for ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
Source§impl<M, T> IntoMultiValue for ManagedVec<M, T>
impl<M, T> IntoMultiValue for ManagedVec<M, T>
type MultiValue = MultiValueEncoded<M, <T as IntoMultiValue>::MultiValue>
fn into_multi_value(self) -> Self::MultiValue
Source§impl<M, T> ManagedType<M> for ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<M, T> ManagedType<M> for ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
type OwnHandle = <M as HandleTypeInfo>::ManagedBufferHandle
fn get_handle(&self) -> M::ManagedBufferHandle
Source§unsafe fn forget_into_handle(self) -> Self::OwnHandle
unsafe fn forget_into_handle(self) -> Self::OwnHandle
Source§fn transmute_from_handle_ref(handle_ref: &M::ManagedBufferHandle) -> &Self
fn transmute_from_handle_ref(handle_ref: &M::ManagedBufferHandle) -> &Self
fn transmute_from_handle_ref_mut( handle_ref: &mut M::ManagedBufferHandle, ) -> &mut Self
fn get_raw_handle(&self) -> RawHandle
fn as_ref(&self) -> ManagedRef<'_, M, Self>
Source§impl<M, T> ManagedVecItem for ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
impl<M, T> ManagedVecItem for ManagedVec<M, T>where
M: ManagedTypeApi,
T: ManagedVecItem,
Source§const SKIPS_RESERIALIZATION: bool = false
const SKIPS_RESERIALIZATION: bool = false
u32
).Source§type PAYLOAD = ManagedVecItemPayloadBuffer<4>
type PAYLOAD = ManagedVecItemPayloadBuffer<4>
Source§type Ref<'a> = ManagedRef<'a, M, ManagedVec<M, T>>
type Ref<'a> = ManagedRef<'a, M, ManagedVec<M, T>>
Source§fn read_from_payload(payload: &Self::PAYLOAD) -> Self
fn read_from_payload(payload: &Self::PAYLOAD) -> Self
Source§unsafe fn borrow_from_payload<'a>(payload: &Self::PAYLOAD) -> Self::Ref<'a>
unsafe fn borrow_from_payload<'a>(payload: &Self::PAYLOAD) -> Self::Ref<'a>
Source§fn save_to_payload(self, payload: &mut Self::PAYLOAD)
fn save_to_payload(self, payload: &mut Self::PAYLOAD)
fn payload_size() -> usize
Source§impl<M, T> NestedDecode for ManagedVec<M, T>
impl<M, T> NestedDecode for ManagedVec<M, T>
Source§fn dep_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<Self, H::HandledErr>where
I: NestedDecodeInput,
H: DecodeErrorHandler,
fn dep_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<Self, H::HandledErr>where
I: NestedDecodeInput,
H: DecodeErrorHandler,
dep_decode
that can handle errors as soon as they occur.
For instance in can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.Source§fn dep_decode<I>(input: &mut I) -> Result<Self, DecodeError>where
I: NestedDecodeInput,
fn dep_decode<I>(input: &mut I) -> Result<Self, DecodeError>where
I: NestedDecodeInput,
Source§impl<M, T> NestedEncode for ManagedVec<M, T>
impl<M, T> NestedEncode for ManagedVec<M, T>
Source§fn dep_encode_or_handle_err<O, H>(
&self,
dest: &mut O,
h: H,
) -> Result<(), H::HandledErr>where
O: NestedEncodeOutput,
H: EncodeErrorHandler,
fn dep_encode_or_handle_err<O, H>(
&self,
dest: &mut O,
h: H,
) -> Result<(), H::HandledErr>where
O: NestedEncodeOutput,
H: EncodeErrorHandler,
dep_encode
that can handle errors as soon as they occur.
For instance in can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.Source§fn dep_encode<O>(&self, dest: &mut O) -> Result<(), EncodeError>where
O: NestedEncodeOutput,
fn dep_encode<O>(&self, dest: &mut O) -> Result<(), EncodeError>where
O: NestedEncodeOutput,
Source§impl<M, T> PartialEq for ManagedVec<M, T>
impl<M, T> PartialEq for ManagedVec<M, T>
Source§impl<M, T> TopDecode for ManagedVec<M, T>
impl<M, T> TopDecode for ManagedVec<M, T>
Source§fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>where
I: TopDecodeInput,
H: DecodeErrorHandler,
fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>where
I: TopDecodeInput,
H: DecodeErrorHandler,
top_decode
that can handle errors as soon as they occur.
For instance it can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.Source§fn top_decode<I>(input: I) -> Result<Self, DecodeError>where
I: TopDecodeInput,
fn top_decode<I>(input: I) -> Result<Self, DecodeError>where
I: TopDecodeInput,
Source§impl<M, T> TopEncode for ManagedVec<M, T>
impl<M, T> TopEncode for ManagedVec<M, T>
Source§fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H,
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H,
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
top_encode
that can handle errors as soon as they occur.
For instance in can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.Source§fn top_encode<O>(&self, output: O) -> Result<(), EncodeError>where
O: TopEncodeOutput,
fn top_encode<O>(&self, output: O) -> Result<(), EncodeError>where
O: TopEncodeOutput,
Source§impl<M> TopEncodeMultiOutput for ManagedVec<M, ManagedBuffer<M>>where
M: ManagedTypeApi,
impl<M> TopEncodeMultiOutput for ManagedVec<M, ManagedBuffer<M>>where
M: ManagedTypeApi,
fn push_single_value<T, H>(
&mut self,
arg: &T,
h: H,
) -> Result<(), H::HandledErr>where
T: TopEncode,
H: EncodeErrorHandler,
Source§fn push_multi_specialized<T, H>(
&mut self,
_arg: &T,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
T: TryStaticCast,
H: EncodeErrorHandler,
fn push_multi_specialized<T, H>(
&mut self,
_arg: &T,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
T: TryStaticCast,
H: EncodeErrorHandler,
Source§impl<M, T> TypeAbi for ManagedVec<M, T>
impl<M, T> TypeAbi for ManagedVec<M, T>
type Unmanaged = Vec<<T as TypeAbi>::Unmanaged>
fn type_name_rust() -> TypeName
Source§fn provide_type_descriptions<TDC: TypeDescriptionContainer>(
accumulator: &mut TDC,
)
fn provide_type_descriptions<TDC: TypeDescriptionContainer>( accumulator: &mut TDC, )
fn type_names() -> TypeNames
impl<M, T> Eq for ManagedVec<M, T>
impl<M, T, U> TypeAbiFrom<ManagedVec<M, U>> for ManagedVec<M, T>
impl<M, T, U> TypeAbiFrom<ManagedVec<M, U>> for Vec<T>
impl<M, T, U> TypeAbiFrom<Vec<U>> for ManagedVec<M, T>
Auto Trait Implementations§
impl<M, T> Freeze for ManagedVec<M, T>
impl<M, T> RefUnwindSafe for ManagedVec<M, T>
impl<M, T> Send for ManagedVec<M, T>
impl<M, T> Sync for ManagedVec<M, T>
impl<M, T> Unpin for ManagedVec<M, T>
impl<M, T> UnwindSafe for ManagedVec<M, T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SCCodec for Twhere
T: TopEncode,
impl<T> SCCodec for Twhere
T: TopEncode,
fn fmt<F>(&self, f: &mut F)where
F: FormatByteReceiver,
Source§impl<T> TopDecodeMulti for Twhere
T: TopDecode,
impl<T> TopDecodeMulti for Twhere
T: TopDecode,
Source§const IS_SINGLE_VALUE: bool = true
const IS_SINGLE_VALUE: bool = true
fn multi_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<T, <H as DecodeErrorHandler>::HandledErr>where
I: TopDecodeMultiInput,
H: DecodeErrorHandler,
fn multi_decode<I>(input: &mut I) -> Result<Self, DecodeError>where
I: TopDecodeMultiInput,
Source§impl<T> TopDecodeMultiLength for T
impl<T> TopDecodeMultiLength for T
Source§impl<T> TopEncodeMulti for Twhere
T: TopEncode,
impl<T> TopEncodeMulti for Twhere
T: TopEncode,
Source§fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
top_encode
that can handle errors as soon as they occur.
For instance in can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.