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 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/protocol/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
§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,
sourcepub fn prepare_sign(&mut self)
pub fn prepare_sign(&mut self)
It is empty, because specification says nothing: https://github.com/FuelLabs/fuel-specs/blob/master/src/protocol/tx_format/input.md#inputmessage
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
Trait Implementations§
source§impl<Specification> Clone for Message<Specification>where
Specification: MessageSpecification + Clone,
Specification::Witness: Clone,
Specification::Data: Clone,
Specification::Predicate: Clone,
Specification::PredicateData: Clone,
impl<Specification> Clone for Message<Specification>where Specification: MessageSpecification + Clone, Specification::Witness: 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::Data: Default,
Specification::Predicate: Default,
Specification::PredicateData: Default,
impl<Specification> Default for Message<Specification>where Specification: MessageSpecification + Default, Specification::Witness: Default, Specification::Data: Default, Specification::Predicate: Default, Specification::PredicateData: Default,
source§impl<Specification> Hash for Message<Specification>where
Specification: MessageSpecification + Hash,
Specification::Witness: Hash,
Specification::Data: Hash,
Specification::Predicate: Hash,
Specification::PredicateData: Hash,
impl<Specification> Hash for Message<Specification>where Specification: MessageSpecification + Hash, Specification::Witness: Hash, Specification::Data: Hash, Specification::Predicate: Hash, Specification::PredicateData: Hash,
source§impl<Specification> PartialEq<Message<Specification>> for Message<Specification>where
Specification: MessageSpecification + PartialEq,
Specification::Witness: PartialEq,
Specification::Data: PartialEq,
Specification::Predicate: PartialEq,
Specification::PredicateData: PartialEq,
impl<Specification> PartialEq<Message<Specification>> for Message<Specification>where Specification: MessageSpecification + PartialEq, Specification::Witness: PartialEq, Specification::Data: PartialEq, Specification::Predicate: PartialEq, Specification::PredicateData: PartialEq,
source§impl<Specification> Read for Message<Specification>where
Specification: MessageSpecification,
impl<Specification> Read for Message<Specification>where Specification: MessageSpecification,
source§fn read(&mut self, full_buf: &mut [u8]) -> Result<usize>
fn read(&mut self, full_buf: &mut [u8]) -> Result<usize>
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
buf
. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,
Read
. Read moresource§impl<Specification> SizedBytes for Message<Specification>where
Specification: MessageSpecification,
impl<Specification> SizedBytes for Message<Specification>where Specification: MessageSpecification,
source§fn serialized_size(&self) -> usize
fn serialized_size(&self) -> usize
source§impl<Specification> Write for Message<Specification>where
Specification: MessageSpecification,
impl<Specification> Write for Message<Specification>where Specification: MessageSpecification,
source§fn write(&mut self, full_buf: &[u8]) -> Result<usize>
fn write(&mut self, full_buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)