Function gstd::msg::load

source ·
pub fn load<D: Decode>() -> Result<D>
Expand description

Get a payload of the message that is currently being processed.

This function returns the decoded message’s payload of a custom type.

Generic D type should implement the Decode trait.

§Examples

use gstd::{msg, prelude::*};

#[derive(Decode)]
#[codec(crate = gstd::codec)]
struct Input {
    field: String,
}

#[no_mangle]
extern "C" fn handle() {
    let payload: Input = msg::load().expect("Unable to load");
    msg::reply(payload.field, 0).expect("Unable to reply");
}

§See also

  • load_bytes function returns a payload as a byte vector.