Struct gear_core::message::MessageContext
source · pub struct MessageContext { /* private fields */ }
Expand description
Context of currently processing incoming message.
Implementations§
source§impl MessageContext
impl MessageContext
sourcepub fn new(
dispatch: IncomingDispatch,
program_id: ProgramId,
settings: ContextSettings
) -> Self
pub fn new( dispatch: IncomingDispatch, program_id: ProgramId, settings: ContextSettings ) -> Self
Create new MessageContext with given ContextSettings.
sourcepub fn settings(&self) -> &ContextSettings
pub fn settings(&self) -> &ContextSettings
Getter for inner settings.
sourcepub fn reply_sent(&self) -> bool
pub fn reply_sent(&self) -> bool
Return bool defining was reply sent within the execution.
sourcepub fn init_program(
&mut self,
packet: InitPacket,
delay: u32
) -> Result<(MessageId, ProgramId), Error>
pub fn init_program( &mut self, packet: InitPacket, delay: u32 ) -> Result<(MessageId, ProgramId), Error>
Send a new program initialization message.
Generates a new message from provided data packet. Returns message id and generated program id.
sourcepub fn send_commit(
&mut self,
handle: u32,
packet: HandlePacket,
delay: u32,
reservation: Option<ReservationId>
) -> Result<MessageId, Error>
pub fn send_commit( &mut self, handle: u32, packet: HandlePacket, delay: u32, reservation: Option<ReservationId> ) -> Result<MessageId, Error>
Send a new program initialization message.
Generates message from provided data packet and stored by handle payload. Returns message id.
sourcepub fn send_init(&mut self) -> Result<u32, Error>
pub fn send_init(&mut self) -> Result<u32, Error>
Provide space for storing payload for future message creation.
Returns it’s handle.
sourcepub fn send_push(&mut self, handle: u32, buffer: &[u8]) -> Result<(), Error>
pub fn send_push(&mut self, handle: u32, buffer: &[u8]) -> Result<(), Error>
Pushes payload into stored payload by handle.
sourcepub fn send_push_input(
&mut self,
handle: u32,
range: CheckedRange
) -> Result<(), Error>
pub fn send_push_input( &mut self, handle: u32, range: CheckedRange ) -> Result<(), Error>
Pushes the incoming buffer/payload into stored payload by handle.
sourcepub fn check_input_range(&self, offset: u32, len: u32) -> CheckedRange
pub fn check_input_range(&self, offset: u32, len: u32) -> CheckedRange
Check if provided offset
/len
are correct for the current payload
limits. Result CheckedRange
instance is accepted by
send_push_input
/reply_push_input
and has the method len
allowing to charge gas before the calls.
sourcepub fn reply_commit(
&mut self,
packet: ReplyPacket,
reservation: Option<ReservationId>
) -> Result<MessageId, ExtError>
pub fn reply_commit( &mut self, packet: ReplyPacket, reservation: Option<ReservationId> ) -> Result<MessageId, ExtError>
Send reply message.
Generates reply from provided data packet and stored reply payload. Returns message id.
sourcepub fn reply_push(&mut self, buffer: &[u8]) -> Result<(), ExtError>
pub fn reply_push(&mut self, buffer: &[u8]) -> Result<(), ExtError>
Pushes payload into stored reply payload.
sourcepub fn reply_destination(&self) -> ProgramId
pub fn reply_destination(&self) -> ProgramId
Return reply destination.
sourcepub fn reply_push_input(&mut self, range: CheckedRange) -> Result<(), ExtError>
pub fn reply_push_input(&mut self, range: CheckedRange) -> Result<(), ExtError>
Pushes the incoming message buffer into stored reply payload.
sourcepub fn wake(&mut self, waker_id: MessageId, delay: u32) -> Result<(), Error>
pub fn wake(&mut self, waker_id: MessageId, delay: u32) -> Result<(), Error>
Wake message by it’s message id.
sourcepub fn reply_deposit(
&mut self,
message_id: MessageId,
amount: u64
) -> Result<(), MessageError>
pub fn reply_deposit( &mut self, message_id: MessageId, amount: u64 ) -> Result<(), MessageError>
Create deposit to handle future reply on message id was sent.
sourcepub fn current(&self) -> &IncomingMessage
pub fn current(&self) -> &IncomingMessage
Current processing incoming message.
sourcepub fn payload_mut(&mut self) -> &mut Payload
pub fn payload_mut(&mut self) -> &mut Payload
Mutable reference to currently processed incoming message.
sourcepub fn program_id(&self) -> ProgramId
pub fn program_id(&self) -> ProgramId
Current program’s id.
sourcepub fn drain(self) -> (ContextOutcome, ContextStore)
pub fn drain(self) -> (ContextOutcome, ContextStore)
Destructs context after execution and returns provided outcome and store.
Trait Implementations§
source§impl Debug for MessageContext
impl Debug for MessageContext
source§impl Decode for MessageContext
impl Decode for MessageContext
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy ) -> Result<Self, Error>
source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
source§impl Encode for MessageContext
impl Encode for MessageContext
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy )
source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl Hash for MessageContext
impl Hash for MessageContext
source§impl Ord for MessageContext
impl Ord for MessageContext
source§fn cmp(&self, other: &MessageContext) -> Ordering
fn cmp(&self, other: &MessageContext) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for MessageContext
impl PartialEq for MessageContext
source§fn eq(&self, other: &MessageContext) -> bool
fn eq(&self, other: &MessageContext) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for MessageContext
impl PartialOrd for MessageContext
source§fn partial_cmp(&self, other: &MessageContext) -> Option<Ordering>
fn partial_cmp(&self, other: &MessageContext) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more