Struct massa_models::async_msg::AsyncMessage
source · pub struct AsyncMessage {Show 13 fields
pub emission_slot: Slot,
pub emission_index: u64,
pub sender: Address,
pub destination: Address,
pub function: String,
pub max_gas: u64,
pub fee: Amount,
pub coins: Amount,
pub validity_start: Slot,
pub validity_end: Slot,
pub function_params: Vec<u8>,
pub trigger: Option<AsyncMessageTrigger>,
pub can_be_executed: bool,
}Expand description
Structure defining an asynchronous smart contract message
Fields§
§emission_slot: SlotSlot at which the message was emitted
emission_index: u64Index of the emitted message within the emission_slot.
This is used for disambiguate the emission of multiple messages at the same slot.
sender: AddressThe address that sent the message
destination: AddressThe address towards which the message is being sent
function: Stringthe function function name within the destination address’ bytecode
max_gas: u64Maximum gas to use when processing the message
fee: AmountFee paid by the sender when the message is processed.
coins: AmountCoins sent from the sender to the target address of the message. Those coins are spent by the sender address when the message is sent, and credited to the destination address when receiving the message. In case of failure or discard, those coins are reimbursed to the sender.
validity_start: SlotSlot at which the message starts being valid (bound included in the validity range)
validity_end: SlotSlot at which the message stops being valid (bound not included in the validity range)
function_params: Vec<u8>Raw payload parameters to call the function with
trigger: Option<AsyncMessageTrigger>Trigger that define whenever a message can be executed
can_be_executed: boolBoolean that determine if the message can be executed. For messages without filter this boolean is always true.
For messages with filter, this boolean is true if the filter has been matched between validity_start and current slot.
Implementations§
source§impl AsyncMessage
impl AsyncMessage
sourcepub fn new(
emission_slot: Slot,
emission_index: u64,
sender: Address,
destination: Address,
function: String,
max_gas: u64,
fee: Amount,
coins: Amount,
validity_start: Slot,
validity_end: Slot,
function_params: Vec<u8>,
trigger: Option<AsyncMessageTrigger>,
can_be_executed: Option<bool>,
) -> Self
pub fn new( emission_slot: Slot, emission_index: u64, sender: Address, destination: Address, function: String, max_gas: u64, fee: Amount, coins: Amount, validity_start: Slot, validity_end: Slot, function_params: Vec<u8>, trigger: Option<AsyncMessageTrigger>, can_be_executed: Option<bool>, ) -> Self
Take an AsyncMessage and return it
sourcepub fn compute_id(&self) -> AsyncMessageId
pub fn compute_id(&self) -> AsyncMessageId
Compute the ID of the message for use when choosing which operations to keep in priority (highest score) on pool overflow.
Trait Implementations§
source§impl Applicable<AsyncMessageUpdate> for AsyncMessage
impl Applicable<AsyncMessageUpdate> for AsyncMessage
source§fn apply(&mut self, update: AsyncMessageUpdate)
fn apply(&mut self, update: AsyncMessageUpdate)
extends the AsyncMessage with a AsyncMessageUpdate
source§impl Clone for AsyncMessage
impl Clone for AsyncMessage
source§fn clone(&self) -> AsyncMessage
fn clone(&self) -> AsyncMessage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for AsyncMessage
impl Debug for AsyncMessage
source§impl Default for AsyncMessage
impl Default for AsyncMessage
source§impl<'de> Deserialize<'de> for AsyncMessage
impl<'de> Deserialize<'de> for AsyncMessage
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Deserializer<AsyncMessage> for AsyncMessageDeserializer
impl Deserializer<AsyncMessage> for AsyncMessageDeserializer
source§fn deserialize<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>>(
&self,
buffer: &'a [u8],
) -> IResult<&'a [u8], AsyncMessage, E>
fn deserialize<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>>( &self, buffer: &'a [u8], ) -> IResult<&'a [u8], AsyncMessage, E>
§Example
use massa_models::{address::Address, amount::Amount, slot::Slot, async_msg::{AsyncMessage, AsyncMessageSerializer, AsyncMessageDeserializer, AsyncMessageTrigger}};
use massa_serialization::{Serializer, Deserializer, DeserializeError};
use std::str::FromStr;
let message = AsyncMessage::new(
Slot::new(1, 0),
0,
Address::from_str("AU12dG5xP1RDEB5ocdHkymNVvvSJmUL9BgHwCksDowqmGWxfpm93x").unwrap(),
Address::from_str("AS12htxRWiEm8jDJpJptr6cwEhWNcCSFWstN1MLSa96DDkVM9Y42G").unwrap(),
String::from("test"),
10000000,
Amount::from_str("1").unwrap(),
Amount::from_str("1").unwrap(),
Slot::new(2, 0),
Slot::new(3, 0),
vec![1, 2, 3, 4],
Some(AsyncMessageTrigger {
address: Address::from_str("AU12dG5xP1RDEB5ocdHkymNVvvSJmUL9BgHwCksDowqmGWxfpm93x").unwrap(),
datastore_key: Some(vec![1, 2, 3, 4]),
}),
None,
);
let message_serializer = AsyncMessageSerializer::new(false);
let mut serialized = Vec::new();
message_serializer.serialize(&message, &mut serialized).unwrap();
let message_deserializer = AsyncMessageDeserializer::new(32, 10000, 100000, 255, false);
// dbg!(&serialized);
let (rest, message_deserialized) = message_deserializer.deserialize::<DeserializeError>(&serialized).unwrap();
assert!(rest.is_empty());
assert_eq!(message, message_deserialized);source§impl From<AsyncMessage> for AsyncMessage
impl From<AsyncMessage> for AsyncMessage
source§fn from(value: AsyncMessage) -> Self
fn from(value: AsyncMessage) -> Self
source§impl PartialEq for AsyncMessage
impl PartialEq for AsyncMessage
source§fn eq(&self, other: &AsyncMessage) -> bool
fn eq(&self, other: &AsyncMessage) -> bool
self and other values to be equal, and is used
by ==.source§impl Serialize for AsyncMessage
impl Serialize for AsyncMessage
source§impl Serializer<AsyncMessage> for AsyncMessageSerializer
impl Serializer<AsyncMessage> for AsyncMessageSerializer
source§fn serialize(
&self,
value: &AsyncMessage,
buffer: &mut Vec<u8>,
) -> Result<(), SerializeError>
fn serialize( &self, value: &AsyncMessage, buffer: &mut Vec<u8>, ) -> Result<(), SerializeError>
§Example
use massa_models::{address::Address, amount::Amount, slot::Slot, async_msg::{AsyncMessage, AsyncMessageSerializer, AsyncMessageTrigger}};
use massa_serialization::Serializer;
use std::str::FromStr;
let message = AsyncMessage::new(
Slot::new(1, 0),
0,
Address::from_str("AU12dG5xP1RDEB5ocdHkymNVvvSJmUL9BgHwCksDowqmGWxfpm93x").unwrap(),
Address::from_str("AU12htxRWiEm8jDJpJptr6cwEhWNcCSFWstN1MLSa96DDkVM9Y42G").unwrap(),
String::from("test"),
10000000,
Amount::from_str("1").unwrap(),
Amount::from_str("1").unwrap(),
Slot::new(2, 0),
Slot::new(3, 0),
vec![1, 2, 3, 4],
Some(AsyncMessageTrigger {
address: Address::from_str("AU12dG5xP1RDEB5ocdHkymNVvvSJmUL9BgHwCksDowqmGWxfpm93x").unwrap(),
datastore_key: Some(vec![1, 2, 3, 4])
}),
None,
);
let mut buffer = Vec::new();
let message_serializer = AsyncMessageSerializer::new(false);
message_serializer.serialize(&message, &mut buffer).unwrap();impl Eq for AsyncMessage
impl StructuralPartialEq for AsyncMessage
Auto Trait Implementations§
impl Freeze for AsyncMessage
impl RefUnwindSafe for AsyncMessage
impl Send for AsyncMessage
impl Sync for AsyncMessage
impl Unpin for AsyncMessage
impl UnwindSafe for AsyncMessage
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§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
§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
§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.§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.§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.§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.§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.