[][src]Macro hdk::link

macro_rules! link {
    (
        direction: $direction:expr,
        other_type: $other_type:expr,
        link_type: $link_type:expr,

        validation_package: || $package_creator:expr,
        validation: | $validation_data:ident : hdk::LinkValidationData | $link_validation:expr
    ) => { ... };
}

The link macro is a helper for creating ValidatingEntryType definitions for use within the entry macro. It has 5 component parts:

  1. direction: direction defines if this entry type (in which the link is defined) points to another entry, or if it is referenced from another entry. The latter is needed in cases where the definition of the entry to link from is not accessible because it is a system entry type (AGENT_ADDRESS), or the other entry is defined in library zome. Must be of type LinkDirection, so either hdk::LinkDirection::To or hdk::LinkDirection::From.
  2. other_type: other_type is the entry type this link connects to. If direction is to this would be the link target, if direction is from this defines the link's base type.
  3. link_type: link_type is the name of this association and thus the handle by which it can be retrieved if given to get_links() in conjunction with the base address.
  4. validation_package: Similar to entries, links have to be validated. validation_package is a special identifier, which declares which data is required from peers when attempting to validate entries of this type. Possible values are found within ValidationPackageDefinition
  5. validation: validation is a callback function which will be called any time that a (DHT) node processes or stores a link of this kind, triggered through the link actions link_entries and remove_link. It always expects three arguments, the first being the base and the second the target of the link. The third is the validation context, which offers a variety of metadata useful for validation. See ValidationData for more details.