holochain_entry_utils 0.1.6

Holochain utilities around entries with default behaviours
Documentation

holochain_entry_utils

Holochain utilities crate around entries, implementing common behaviour and functions.

Usage

Add this dependency to your Cargo.toml:

[dependencies]
holochain_entry_utils = "0.1.1"

Implement the HolochainEntry trait:

    use holochain_entry_utils::HolochainEntry;

    #[derive(Serialize, Deserialize, Debug, DefaultJson, Clone)]
    pub struct TestEntry {
        contents: String,
    }

    impl HolochainEntry for TestEntry {
        fn entry_type() -> String {
            String::from("test_type")
        }
    }

    pub fn entry_def() -> ValidatingEntryType {
        entry!(
            name: TestEntry::entry_type(),
        ...
    }

And now the functions defined in the Trait (see documentation) are available for you to use:

pub fn test_function(test_entry: TestEntry) -> ZomeApiResult<Address> {
    hdk::commit_entry(&test_entry.entry())
}