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 ) -> Self

Create new MessageContext with given ContextSettings.

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) -> 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.

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
source§

impl Decode for MessageContext

source§

fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy ) -> Result<Self, Error>

Attempt to deserialise the value from input.
source§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self> ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
source§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
source§

impl Encode for MessageContext

source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
source§

fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy )

Convert self to a slice and append it to the destination.
source§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
source§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
source§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
source§

impl Hash for MessageContext

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for MessageContext

source§

fn cmp(&self, other: &MessageContext) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for MessageContext

source§

fn eq(&self, other: &MessageContext) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for MessageContext

source§

fn partial_cmp(&self, other: &MessageContext) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TypeInfo for MessageContext

§

type Identity = MessageContext

The type identifying for which type info is provided. Read more
source§

fn type_info() -> Type

Returns the static type identifier for Self.
source§

impl EncodeLike for MessageContext

source§

impl Eq for MessageContext

source§

impl StructuralEq for MessageContext

source§

impl StructuralPartialEq for MessageContext

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> DecodeAll for T
where T: Decode,

source§

fn decode_all(input: &mut &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
source§

impl<T> DecodeLimit for T
where T: Decode,

source§

fn decode_all_with_depth_limit( limit: u32, input: &mut &[u8] ) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
source§

fn decode_with_depth_limit<I>(limit: u32, input: &mut I) -> Result<T, Error>
where I: Input,

Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> KeyedVec for T
where T: Codec,

source§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>

Return an encoding of Self prepended by given slice.
source§

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

§

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>,

§

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<S> Codec for S
where S: Decode + Encode,

source§

impl<T> EncodeLike<&&T> for T
where T: Encode,

source§

impl<T> EncodeLike<&T> for T
where T: Encode,

source§

impl<T> EncodeLike<&mut T> for T
where T: Encode,

source§

impl<T> EncodeLike<Arc<T>> for T
where T: Encode,

source§

impl<T> EncodeLike<Box<T>> for T
where T: Encode,

source§

impl<T> EncodeLike<Rc<T>> for T
where T: Encode,

source§

impl<S> FullCodec for S
where S: Decode + FullEncode,

source§

impl<S> FullEncode for S
where S: Encode + EncodeLike,

source§

impl<T> JsonSchemaMaybe for T

source§

impl<T> StaticTypeInfo for T
where T: TypeInfo + 'static,