Function gcore::msg::reply_commit

source ·
pub fn reply_commit(value: u128) -> Result<MessageId>
Expand description

Finalize and send the current reply message.

Some programs can rely on their messages to other programs, i.e., check another program’s state and use it as a parameter for its own business logic. The basic implementation is covered in reply function.

This function allows sending a reply message filled with payload parts via reply_push during the message handling. The reply_commit function finalizes the reply message and sends it to the program invoker.

The only argument is the value to be transferred from the current program account to the reply message target account.

Note that an incomplete reply message will be dropped if the reply_commit function has not been called before the current execution ends.

§Examples

use gcore::msg;

#[no_mangle]
extern "C" fn handle() {
    msg::reply_push(b"Hello,").expect("Unable to push");
    msg::reply_push(b" world!").expect("Unable to push");
    msg::reply_commit(42).expect("Unable to commit");
}

§See also

  • reply_push function allows forming a reply message in parts.
  • send_commit function finalizes and sends a message formed in parts.