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,
) -> Option<Self>
pub fn new( dispatch: IncomingDispatch, program_id: ProgramId, settings: ContextSettings, ) -> Option<Self>
Create new message context.
Returns None
if outgoing messages bytes limit exceeded.
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,
) -> Result<CheckedRange, Error>
pub fn check_input_range( &self, offset: u32, len: u32, ) -> Result<CheckedRange, Error>
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.