Function gstd::msg::reply_bytes

source ·
pub fn reply_bytes(payload: impl AsRef<[u8]>, value: u128) -> Result<MessageId>
Expand description

Send a new message as a reply to the message that is currently being processed.

Various programs can communicate with each other, e.g., check another program’s state and use it as a parameter for its business logic.

This function allows sending such replies, which are similar to standard messages in terms of payload and different only in how the message processing is handled by a dedicated program function called handle_reply.

The first argument is the payload buffer. The second argument is the value to be transferred from the current program account to the reply message target account.

Reply message transactions will be posted after processing is complete, similar to the standard message-sending function (e.g. send_bytes).

§Examples

use gstd::{exec, msg};

#[no_mangle]
extern "C" fn handle() {
    msg::reply_bytes(b"PING", exec::value_available()).expect("Unable to reply");
}

§See also

  • reply function sends a reply with an encoded payload.
  • reply_push, reply_commit functions allow forming a reply message in parts.
  • send_bytes function sends a new message to the program or user.