Macro hdk_crud::crud[][src]

macro_rules! crud {
    ($crud_type : ident, $i : ident, $path : expr, $get_peers : ident,
 $convert_to_receiver_signal : ident) => { ... };
}
Expand description

A macro to go quick and easy from having just a Holochain entry definition to having a full create-read-update-delete set of functionality in your Zome, plus “signals” (events). See example for a comprehensive look at how this works.

use hdk::prelude::*;
use hdk_crud::*;

#[hdk_entry(id = "test")]
#[derive(Clone, PartialEq)]
pub struct Test {
    pub number: i32,
}
// ExampleSignal pops out of the crud! macro
#[derive(Debug, Serialize, Deserialize, SerializedBytes)]
#[serde(untagged)]
pub enum TestSignalTypes {
    Test(TestSignal)
}
pub fn convert_to_receiver_signal(signal: TestSignal) -> TestSignalTypes {
    TestSignalTypes::Test(signal)
}
pub fn get_peers() -> ExternResult<Vec<AgentPubKey>> {
    Ok(Vec::new())
}
crud!(
    Test,
    test,
    "test",
    get_peers,
    convert_to_receiver_signal
);