Struct elrond_wasm::types::ManagedBuffer [−][src]
pub struct ManagedBuffer<M: ManagedTypeApi> { /* fields omitted */ }
Expand description
A byte buffer managed by an external API.
Implementations
pub fn load_slice(
&self,
starting_position: usize,
dest_slice: &mut [u8]
) -> Result<(), InvalidSliceError>
pub fn load_slice(
&self,
starting_position: usize,
dest_slice: &mut [u8]
) -> Result<(), InvalidSliceError>
TODO: investigate the impact of using Result<(), ()>
on the wasm output.
pub fn copy_slice(
&self,
starting_position: usize,
slice_len: usize
) -> Option<ManagedBuffer<M>>
Utility function: helps serialize lengths (or any other value of type usize) easier.
Trait Implementations
Syntactic sugar only.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Size of the data stored in the underlying ManagedBuffer
.
If true, then the encoding of the item is identical to the payload,
and no further conversion is necessary
(the underlying buffer can be used as-is during serialization).
False for all managed types, but true for basic types (like u32
). Read more
Attempt to deserialise the value from input, using the format of an object nested inside another structure. In case of success returns the deserialized value and the number of bytes consumed during the operation. Read more
fn dep_decode_or_exit<I: NestedDecodeInput, ExitCtx: Clone>(
input: &mut I,
c: ExitCtx,
exit: fn(_: ExitCtx, _: DecodeError) -> !
) -> Self
fn dep_decode_or_exit<I: NestedDecodeInput, ExitCtx: Clone>(
input: &mut I,
c: ExitCtx,
exit: fn(_: ExitCtx, _: DecodeError) -> !
) -> Self
Version of top_decode
that exits quickly in case of error.
Its purpose is to create smaller implementations
in cases where the application is supposed to exit directly on decode error. Read more
NestedEncode to output, using the format of an object nested inside another structure. Does not provide compact version. Read more
fn dep_encode_or_exit<O, ExitCtx>(
&self,
dest: &mut O,
c: ExitCtx,
exit: fn(ExitCtx, EncodeError) -> !
) where
O: NestedEncodeOutput,
ExitCtx: Clone,
fn dep_encode_or_exit<O, ExitCtx>(
&self,
dest: &mut O,
c: ExitCtx,
exit: fn(ExitCtx, EncodeError) -> !
) where
O: NestedEncodeOutput,
ExitCtx: Clone,
Version of top_decode
that exits quickly in case of error.
Its purpose is to create smaller implementations
in cases where the application is supposed to exit directly on decode error. Read more
fn push_specialized<T, C, F>(
&mut self,
context: C,
value: &T,
else_serialization: F
) -> Result<(), EncodeError> where
T: TryStaticCast,
C: TryStaticCast,
F: FnOnce(&mut Self) -> Result<(), EncodeError>,
Attempt to deserialize the value from input.
fn top_decode_or_exit<I, ExitCtx>(
input: I,
c: ExitCtx,
exit: fn(ExitCtx, DecodeError) -> !
) -> Self where
I: TopDecodeInput,
ExitCtx: Clone,
fn top_decode_or_exit<I, ExitCtx>(
input: I,
c: ExitCtx,
exit: fn(ExitCtx, DecodeError) -> !
) -> Self where
I: TopDecodeInput,
ExitCtx: Clone,
Version of top_decode
that exits quickly in case of error.
Its purpose is to create smaller implementations
in cases where the application is supposed to exit directly on decode error. Read more
type NestedBuffer = ManagedBufferNestedDecodeInput<M>
fn into_boxed_slice_u8(self) -> Box<[u8]>ⓘ
fn into_boxed_slice_u8(self) -> Box<[u8]>ⓘ
Provides the underlying data as an owned byte slice box. Consumes the input object in the process. Read more
Retrieves the underlying data as a pre-parsed u64. Expected to panic if the conversion is not possible. Read more
fn into_specialized<T, F>(self, else_deser: F) -> Result<T, DecodeError> where
T: TryStaticCast,
F: FnOnce(Self) -> Result<T, DecodeError>,
Retrieves the underlying data as a pre-parsed i64. Expected to panic if the conversion is not possible. Read more
fn into_specialized_or_exit<T, F, ExitCtx>(
self,
c: ExitCtx,
exit: fn(ExitCtx, DecodeError) -> !,
else_deser: F
) -> T where
T: TryStaticCast,
ExitCtx: Clone,
F: FnOnce(Self, ExitCtx, fn(ExitCtx, DecodeError) -> !) -> T,
fn into_specialized_or_exit<T, F, ExitCtx>(
self,
c: ExitCtx,
exit: fn(ExitCtx, DecodeError) -> !,
else_deser: F
) -> T where
T: TryStaticCast,
ExitCtx: Clone,
F: FnOnce(Self, ExitCtx, fn(ExitCtx, DecodeError) -> !) -> T,
Note: currently not in use.
Attempt to serialize the value to ouput.
fn top_encode_or_exit<O, ExitCtx>(
&self,
output: O,
c: ExitCtx,
exit: fn(ExitCtx, EncodeError) -> !
) where
O: TopEncodeOutput,
ExitCtx: Clone,
fn top_encode_or_exit<O, ExitCtx>(
&self,
output: O,
c: ExitCtx,
exit: fn(ExitCtx, EncodeError) -> !
) where
O: TopEncodeOutput,
ExitCtx: Clone,
Version of top_decode
that exits quickly in case of error.
Its purpose is to create smaller bytecode implementations
in cases where the application is supposed to exit directly on decode error. Read more
type NestedBuffer = ManagedBuffer<M>
type NestedBuffer = ManagedBuffer<M>
Type of NestedEncodeOutput
that can be spawned to gather serializations of children.
fn set_specialized<T, F>(
self,
value: &T,
else_serialization: F
) -> Result<(), EncodeError> where
T: TryStaticCast,
F: FnOnce(Self) -> Result<(), EncodeError>,
fn set_specialized<T, F>(
self,
value: &T,
else_serialization: F
) -> Result<(), EncodeError> where
T: TryStaticCast,
F: FnOnce(Self) -> Result<(), EncodeError>,
Allows special handling of special types.
Also requires an alternative serialization, in case the special handling is not covered.
The alternative serialization, else_serialization
is only called when necessary and
is normally compiled out via monomorphization. Read more
type Error = DecodeError
type Error = DecodeError
The type returned in the event of a conversion error.
Performs the conversion.
impl<M, const N: usize> TryFrom<ManagedBuffer<M>> for ManagedByteArray<M, N> where
M: ManagedTypeApi,
impl<M, const N: usize> TryFrom<ManagedBuffer<M>> for ManagedByteArray<M, N> where
M: ManagedTypeApi,
type Error = DecodeError
type Error = DecodeError
The type returned in the event of a conversion error.
Performs the conversion.
A type can provide more than its own description. For instance, a struct can also provide the descriptions of the type of its fields. TypeAbi doesn’t care for the exact accumulator type, which is abstracted by the TypeDescriptionContainer trait. Read more
Auto Trait Implementations
impl<M> RefUnwindSafe for ManagedBuffer<M> where
M: RefUnwindSafe,
impl<M> Send for ManagedBuffer<M> where
M: Send,
impl<M> Sync for ManagedBuffer<M> where
M: Sync,
impl<M> Unpin for ManagedBuffer<M> where
M: Unpin,
impl<M> UnwindSafe for ManagedBuffer<M> where
M: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more