Trait elrond_codec::TopEncode
source · pub trait TopEncode: Sized {
fn top_encode<O>(&self, output: O) -> Result<(), EncodeError>
where
O: TopEncodeOutput,
{ ... }
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H
) -> Result<(), H::HandledErr>
where
O: TopEncodeOutput,
H: EncodeErrorHandler,
{ ... }
}
Provided Methods§
sourcefn top_encode<O>(&self, output: O) -> Result<(), EncodeError>where
O: TopEncodeOutput,
fn top_encode<O>(&self, output: O) -> Result<(), EncodeError>where
O: TopEncodeOutput,
Attempt to serialize the value to ouput.
sourcefn 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,
Version of 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.
Implementations on Foreign Types§
source§impl<T: NestedEncode, const N: usize> TopEncode for [T; N]
impl<T: NestedEncode, const N: usize> TopEncode for [T; N]
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl<T: NestedEncode, const CAP: usize> TopEncode for ArrayVec<T, CAP>
impl<T: NestedEncode, const CAP: usize> TopEncode for ArrayVec<T, CAP>
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for bool
impl TopEncode for bool
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for NonZeroUsize
impl TopEncode for NonZeroUsize
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for i64
impl TopEncode for i64
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for i32
impl TopEncode for i32
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for isize
impl TopEncode for isize
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for i16
impl TopEncode for i16
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for i8
impl TopEncode for i8
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for u64
impl TopEncode for u64
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for u32
impl TopEncode for u32
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for usize
impl TopEncode for usize
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for u16
impl TopEncode for u16
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl TopEncode for u8
impl TopEncode for u8
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
_h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
source§impl<T: NestedEncode> TopEncode for Option<T>
impl<T: NestedEncode> TopEncode for Option<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,
Allow None to be serialized to empty bytes, but leave the leading “1” for Some, to allow disambiguation between e.g. Some(0) and None.
source§impl<T> TopEncode for PhantomData<T>
impl<T> TopEncode for PhantomData<T>
Empty structure with an empty bytes representation. Equivalent to false
, 0
or [u8; 0]
, but more explicit.
Note: the unit type ()
would have naturally fit this role, but we decided to make the unit type multi-value only.