Holochain Anchors

This create allows a Holochain project to easily use the anchors pattern for creating links. This is still a work in progress and feedback would be appreciated.

Install

Add the following to your zomes cargo toml. holochain_anchors = "0.1"

Usage

Add the entry defs to your zome. ```rust #[entrydef] fn anchordef() -> ValidatingEntryType { holochainanchors::anchordefinition() }

[entry_def]

fn rootanchordef() -> ValidatingEntryType { holochainanchors::rootanchordefinition() } Link from the `ANCHOR_TYPE` rust links: [ from!( holochainanchors::ANCHORTYPE, linktype: "mylinktype", validation_package: || { hdk::ValidationPackageDefinition::Entry },

    validation: |_validation_data: hdk::LinkValidationData| {
        Ok(())
    }
)

] Create an anchor and link an entry to it. If the anchor already exists then it will use the existing anchor. rust let myentry = Entry::App( "myentry".into(), MyEntry{ content: "somecontent".into() }.into() ); let address = hdk::commitentry(&myentry)?; let anchoraddress = holochainanchors::createanchor("myanchortype".into(), "myanchor".into())?; hdk::linkentries(&anchoraddress, &address, "mylinktype", "")?; Get all the links on that anchor. rust let anchoraddress = holochainanchors::createanchor("myanchortype".into(), "myanchor".into())?; hdk::utils::getlinksandloadtype(&anchoraddress, LinkMatch::Exactly("mylinktype"), LinkMatch::Any) ```