pub struct Message<Specification>where
Specification: MessageSpecification,{
pub sender: Address,
pub recipient: Address,
pub amount: Word,
pub nonce: Nonce,
pub witness_index: Specification::Witness,
pub predicate_gas_used: Specification::PredicateGasUsed,
pub data: Specification::Data,
pub predicate: Specification::Predicate,
pub predicate_data: Specification::PredicateData,
}
Expand description
It is a full representation of the message from the specification: https://github.com/FuelLabs/fuel-specs/blob/master/src/tx-format/input.md#inputmessage.
The specification defines the layout of the Message
in the serialized form for
the fuel-vm
. But on the business logic level, we don’t use all fields at the same
time. It is why in the super::Input
the message is represented by several forms
based on the usage context. Leaving some fields empty reduces the memory consumption
by the structure and erases the empty useless fields.
The MessageSpecification
trait specifies the sub-messages for the corresponding
usage context. It allows us to write the common logic of all sub-messages without the
overhead and duplication.
Sub-messages from specifications
:
specifications::MessageData
withspecifications::Signed
usage rules.specifications::MessageData
withspecifications::Predicate
usage rules.specifications::Full
.
Fields§
§sender: Address
The sender from the L1 chain.
recipient: Address
The receiver on the Fuel
chain.
amount: Word
§nonce: Nonce
§witness_index: Specification::Witness
§predicate_gas_used: Specification::PredicateGasUsed
§data: Specification::Data
§predicate: Specification::Predicate
§predicate_data: Specification::PredicateData
Implementations§
source§impl<Specification> Message<Specification>where
Specification: MessageSpecification,
impl<Specification> Message<Specification>where
Specification: MessageSpecification,
pub fn prepare_sign(&mut self)
pub fn message_id(&self) -> MessageId
source§impl Message<Full>
impl Message<Full>
pub fn into_message_data_signed(self) -> MessageDataSigned
pub fn into_message_data_predicate(self) -> MessageDataPredicate
pub fn into_coin_signed(self) -> MessageCoinSigned
pub fn into_coin_predicate(self) -> MessageCoinPredicate
source§impl Message<MessageCoin<Signed>>
impl Message<MessageCoin<Signed>>
pub fn into_full(self) -> FullMessage
source§impl Message<MessageCoin<Predicate>>
impl Message<MessageCoin<Predicate>>
pub fn into_full(self) -> FullMessage
source§impl Message<MessageData<Predicate>>
impl Message<MessageData<Predicate>>
pub fn into_full(self) -> FullMessage
source§impl Message<MessageData<Signed>>
impl Message<MessageData<Signed>>
pub fn into_full(self) -> FullMessage
Trait Implementations§
source§impl<Specification> Clone for Message<Specification>where
Specification: MessageSpecification + Clone,
Specification::Witness: Clone,
Specification::PredicateGasUsed: Clone,
Specification::Data: Clone,
Specification::Predicate: Clone,
Specification::PredicateData: Clone,
impl<Specification> Clone for Message<Specification>where
Specification: MessageSpecification + Clone,
Specification::Witness: Clone,
Specification::PredicateGasUsed: Clone,
Specification::Data: Clone,
Specification::Predicate: Clone,
Specification::PredicateData: Clone,
source§impl<Specification> Debug for Message<Specification>where
Specification: MessageSpecification,
impl<Specification> Debug for Message<Specification>where
Specification: MessageSpecification,
source§impl<Specification> Default for Message<Specification>where
Specification: MessageSpecification + Default,
Specification::Witness: Default,
Specification::PredicateGasUsed: Default,
Specification::Data: Default,
Specification::Predicate: Default,
Specification::PredicateData: Default,
impl<Specification> Default for Message<Specification>where
Specification: MessageSpecification + Default,
Specification::Witness: Default,
Specification::PredicateGasUsed: Default,
Specification::Data: Default,
Specification::Predicate: Default,
Specification::PredicateData: Default,
source§impl<Specification> Deserialize for Message<Specification>where
Specification: MessageSpecification,
Specification::Witness: Deserialize,
Specification::PredicateGasUsed: Deserialize,
Specification::Data: Deserialize,
Specification::Predicate: Deserialize,
Specification::PredicateData: Deserialize,
impl<Specification> Deserialize for Message<Specification>where
Specification: MessageSpecification,
Specification::Witness: Deserialize,
Specification::PredicateGasUsed: Deserialize,
Specification::Data: Deserialize,
Specification::Predicate: Deserialize,
Specification::PredicateData: Deserialize,
source§fn decode_static<I: Input + ?Sized>(buffer: &mut I) -> Result<Self, Error>
fn decode_static<I: Input + ?Sized>(buffer: &mut I) -> Result<Self, Error>
Self
from the buffer
.source§fn decode_dynamic<I: Input + ?Sized>(
&mut self,
buffer: &mut I,
) -> Result<(), Error>
fn decode_dynamic<I: Input + ?Sized>( &mut self, buffer: &mut I, ) -> Result<(), Error>
buffer
to fill Self
.
The default implementation does nothing. Dynamically-sized contains should
override this.source§impl<Specification> Hash for Message<Specification>where
Specification: MessageSpecification + Hash,
Specification::Witness: Hash,
Specification::PredicateGasUsed: Hash,
Specification::Data: Hash,
Specification::Predicate: Hash,
Specification::PredicateData: Hash,
impl<Specification> Hash for Message<Specification>where
Specification: MessageSpecification + Hash,
Specification::Witness: Hash,
Specification::PredicateGasUsed: Hash,
Specification::Data: Hash,
Specification::Predicate: Hash,
Specification::PredicateData: Hash,
source§impl<Specification> PartialEq for Message<Specification>where
Specification: MessageSpecification + PartialEq,
Specification::Witness: PartialEq,
Specification::PredicateGasUsed: PartialEq,
Specification::Data: PartialEq,
Specification::Predicate: PartialEq,
Specification::PredicateData: PartialEq,
impl<Specification> PartialEq for Message<Specification>where
Specification: MessageSpecification + PartialEq,
Specification::Witness: PartialEq,
Specification::PredicateGasUsed: PartialEq,
Specification::Data: PartialEq,
Specification::Predicate: PartialEq,
Specification::PredicateData: PartialEq,
source§impl<Specification> Serialize for Message<Specification>where
Specification: MessageSpecification,
Specification::Witness: Serialize,
Specification::PredicateGasUsed: Serialize,
Specification::Data: Serialize,
Specification::Predicate: Serialize,
Specification::PredicateData: Serialize,
impl<Specification> Serialize for Message<Specification>where
Specification: MessageSpecification,
Specification::Witness: Serialize,
Specification::PredicateGasUsed: Serialize,
Specification::Data: Serialize,
Specification::Predicate: Serialize,
Specification::PredicateData: Serialize,
source§fn size_static(&self) -> usize
fn size_static(&self) -> usize
source§fn size_dynamic(&self) -> usize
fn size_dynamic(&self) -> usize
source§fn encode_static<O: Output + ?Sized>(&self, buffer: &mut O) -> Result<(), Error>
fn encode_static<O: Output + ?Sized>(&self, buffer: &mut O) -> Result<(), Error>
Self
.source§fn encode_dynamic<O: Output + ?Sized>(
&self,
buffer: &mut O,
) -> Result<(), Error>
fn encode_dynamic<O: Output + ?Sized>( &self, buffer: &mut O, ) -> Result<(), Error>
Self
.
The default implementation does nothing. Dynamically-sized contains should
override this.source§fn size(&self) -> usize
fn size(&self) -> usize
impl<Specification> Eq for Message<Specification>where
Specification: MessageSpecification + Eq,
Specification::Witness: Eq,
Specification::PredicateGasUsed: Eq,
Specification::Data: Eq,
Specification::Predicate: Eq,
Specification::PredicateData: Eq,
impl<Specification> StructuralPartialEq for Message<Specification>where
Specification: MessageSpecification,
Auto Trait Implementations§
impl<Specification> Freeze for Message<Specification>where
<Specification as MessageSpecification>::Witness: Freeze,
<Specification as MessageSpecification>::PredicateGasUsed: Freeze,
<Specification as MessageSpecification>::Data: Freeze,
<Specification as MessageSpecification>::Predicate: Freeze,
<Specification as MessageSpecification>::PredicateData: Freeze,
impl<Specification> RefUnwindSafe for Message<Specification>where
<Specification as MessageSpecification>::Witness: RefUnwindSafe,
<Specification as MessageSpecification>::PredicateGasUsed: RefUnwindSafe,
<Specification as MessageSpecification>::Data: RefUnwindSafe,
<Specification as MessageSpecification>::Predicate: RefUnwindSafe,
<Specification as MessageSpecification>::PredicateData: RefUnwindSafe,
impl<Specification> Send for Message<Specification>where
<Specification as MessageSpecification>::Witness: Send,
<Specification as MessageSpecification>::PredicateGasUsed: Send,
<Specification as MessageSpecification>::Data: Send,
<Specification as MessageSpecification>::Predicate: Send,
<Specification as MessageSpecification>::PredicateData: Send,
impl<Specification> Sync for Message<Specification>where
<Specification as MessageSpecification>::Witness: Sync,
<Specification as MessageSpecification>::PredicateGasUsed: Sync,
<Specification as MessageSpecification>::Data: Sync,
<Specification as MessageSpecification>::Predicate: Sync,
<Specification as MessageSpecification>::PredicateData: Sync,
impl<Specification> Unpin for Message<Specification>where
<Specification as MessageSpecification>::Witness: Unpin,
<Specification as MessageSpecification>::PredicateGasUsed: Unpin,
<Specification as MessageSpecification>::Data: Unpin,
<Specification as MessageSpecification>::Predicate: Unpin,
<Specification as MessageSpecification>::PredicateData: Unpin,
impl<Specification> UnwindSafe for Message<Specification>where
<Specification as MessageSpecification>::Witness: UnwindSafe,
<Specification as MessageSpecification>::PredicateGasUsed: UnwindSafe,
<Specification as MessageSpecification>::Data: UnwindSafe,
<Specification as MessageSpecification>::Predicate: UnwindSafe,
<Specification as MessageSpecification>::PredicateData: UnwindSafe,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.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>
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>
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 moresource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> StorageAsMut for T
impl<T> StorageAsMut for T
fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
source§impl<T> StorageAsRef for T
impl<T> StorageAsRef for T
fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.