gear_core::message

Struct MessageContext

Source
pub struct MessageContext { /* private fields */ }
Expand description

Context of currently processing incoming message.

Implementations§

Source§

impl MessageContext

Source

pub fn new( dispatch: IncomingDispatch, program_id: ProgramId, settings: ContextSettings, ) -> Option<Self>

Create new message context. Returns None if outgoing messages bytes limit exceeded.

Source

pub fn settings(&self) -> &ContextSettings

Getter for inner settings.

Source

pub fn reply_sent(&self) -> bool

Return bool defining was reply sent within the execution.

Source

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.

Source

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.

Source

pub fn send_init(&mut self) -> Result<u32, Error>

Provide space for storing payload for future message creation.

Returns it’s handle.

Source

pub fn send_push(&mut self, handle: u32, buffer: &[u8]) -> Result<(), Error>

Pushes payload into stored payload by handle.

Source

pub fn send_push_input( &mut self, handle: u32, range: CheckedRange, ) -> Result<(), Error>

Pushes the incoming buffer/payload into stored payload by handle.

Source

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.

Source

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.

Source

pub fn reply_push(&mut self, buffer: &[u8]) -> Result<(), ExtError>

Pushes payload into stored reply payload.

Source

pub fn reply_destination(&self) -> ProgramId

Return reply destination.

Source

pub fn reply_push_input(&mut self, range: CheckedRange) -> Result<(), ExtError>

Pushes the incoming message buffer into stored reply payload.

Source

pub fn wake(&mut self, waker_id: MessageId, delay: u32) -> Result<(), Error>

Wake message by it’s message id.

Source

pub fn reply_deposit( &mut self, message_id: MessageId, amount: u64, ) -> Result<(), MessageError>

Create deposit to handle future reply on message id was sent.

Source

pub fn current(&self) -> &IncomingMessage

Current processing incoming message.

Source

pub fn payload_mut(&mut self) -> &mut Payload

Mutable reference to currently processed incoming message.

Source

pub fn program_id(&self) -> ProgramId

Current program’s id.

Source

pub fn drain(self) -> (ContextOutcome, ContextStore)

Destructs context after execution and returns provided outcome and store.

Trait Implementations§

Source§

impl Debug for MessageContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> JsonSchemaMaybe for T