pub struct ABIDecoder;
Implementations§
Source§impl ABIDecoder
impl ABIDecoder
Sourcepub fn decode(
param_types: &[ParamType],
bytes: &[u8],
) -> Result<Vec<Token>, CodecError>
pub fn decode( param_types: &[ParamType], bytes: &[u8], ) -> Result<Vec<Token>, CodecError>
Decodes types described by param_types
into their respective Token
s
using the data in bytes
and receipts
.
§Arguments
param_types
: The ParamType’s of the types we expect are encoded insidebytes
andreceipts
.bytes
: The bytes to be used in the decoding process.
§Examples
use fuels_core::abi_decoder::ABIDecoder;
use fuels_core::Token;
use fuels_types::param_types::ParamType;
let tokens = ABIDecoder::decode(&[ParamType::U8, ParamType::U8], &[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,2]).unwrap();
assert_eq!(tokens, vec![Token::U8(1), Token::U8(2)])
Sourcepub fn decode_single(
param_type: &ParamType,
bytes: &[u8],
) -> Result<Token, CodecError>
pub fn decode_single( param_type: &ParamType, bytes: &[u8], ) -> Result<Token, CodecError>
The same as decode
just for a single type. Used in most cases since
contract functions can only return one type.
Auto Trait Implementations§
impl Freeze for ABIDecoder
impl RefUnwindSafe for ABIDecoder
impl Send for ABIDecoder
impl Sync for ABIDecoder
impl Unpin for ABIDecoder
impl UnwindSafe for ABIDecoder
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more