[][src]Crate hdk

Holochain Development Kit (HDK)

The HDK helps in writing Holochain applications. Holochain DNAs need to be written in WebAssembly, or a language that compiles to Wasm, such as Rust. The HDK handles some of the low-level details of Wasm execution like memory allocation, (de)serializing data, and shuffling data and functions into and out of Wasm memory via some helper functions and Holochain-specific macros.

The HDK lets the developer focus on application logic and, as much as possible, forget about the underlying low-level implementation. It would be possible to write DNA source code without an HDK, but it would be extremely tedious!

Throughout the development process it will be helpful to click around through this reference, but the most useful places to start reading are the define_zome! macro, and the list of exposed functions that Holochain offers: the API.

Re-exports

pub extern crate serde;
pub extern crate holochain_core_types;
pub extern crate holochain_wasm_utils;
pub use crate::api::*;

Modules

api

This file contains many of the structs, enums, and functions relevant for Zome developers! Detailed references and examples can be found here for how to use the HDK exposed functions to access powerful Holochain functions.

entry_definition

This file contains the macros used for creating validating entry type definitions, and validating links definitions within those.

error

This file contains defitions for Zome errors and also Zome Results.

global_fns

This file contains small helper functions relating to WASM memory management and serialization used throughout the HDK.

globals

Holds the internal/private globals used by the zome api library. Also contains the functions declarations of the external functions provided by the Ribosome.

init_globals

Holds the internal/private zome API function init_globals which initializes the Zome API Globals with the values it receives from the Ribosome. It is automatically called at startup of each Zome function call.

macros

This file contains the define_zome! macro, and smaller helper macros.

meta

This file contains the "secret" functions that get added to Zomes, by the HDK. These functions match expectations that Holochain has... every Zome technically needs these functions, but not every developer should have to write them. A notable function defined here is __hdk_get_json_definition which allows Holochain to retrieve JSON defining the Zome.

Macros

define_zome

Every Zome must utilize the define_zome macro in the main library file in their Zome. The define_zome macro has 4 component parts:

entry

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

from

The from macro is a helper for creating ValidatingEntryType definitions for use within the entry macro. It is a convenience wrapper around link! that has all the same properties except for the direction which gets set to LinkDirection::From.

link

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

to

The to macro is a helper for creating ValidatingEntryType definitions for use within the entry macro. It is a convenience wrapper around link! that has all the same properties except for the direction which gets set to LinkDirection::To.

Structs

EntryValidationArgs
LinkValidationArgs
LinkValidationPackageArgs
ValidationData

This structs carries information contextual for the process of validating an entry of link and is passed in to the according callbacks.

ValidationPackage

Enums

EntryAction
EntryLifecycle
LinkAction
LinkDirection
ValidationPackageDefinition

Constants

THIS_INSTANCE