[][src]Macro active_tx::packet_data

macro_rules! packet_data {
    ($($data:tt)+) => { ... };
}

Packet data macro

This macro can be used to generate PacketValues which are consumed by the PacketBuilder to generate sections of the transaction packet. These are $i (input), $o (output), and $r (readonly).

This macro is designed to be more restrictive than standard JSON. This means that it will only accept objects, string, and arrays. The json! macro in the serde_json crate can be used for more flexibility and passed to the add_json method provided in PacketBuilder.

Examples

let value = packet_data!({"basic": "object"});
// This value can now be passed to the builder for consumption
let builder = PacketBuilder::new(value);


// Objects can be nested
let value = packet_data!({"parent": {"nested": "object"}});

// And arrays can be used
let value = packet_data!({"array": ["1", "2", "3"]});