[][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 use holochain_core_types;
pub use holochain_json_api;
pub use holochain_json_derive;
pub use holochain_persistence_api;
pub use holochain_wasm_utils;
pub use pretty_assertions;
pub use serde;
pub use serde_derive;
pub use serde_json;
pub use crate::api::*;

Modules

api

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.

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.

prelude

Types required by all but the most trivial zomes. This can greatly simplify imports for the majority of developers by simply adding use hdk::prelude::*;

utils

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

AgentIdValidationArgs
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
EntryValidationData

This struct carries information needed for Validating Entry Data, It is passed between callbacks and allows the user to validate using each supplied variant.

LinkAction
LinkDirection
LinkValidationData

This struct carries information needed for Validating Link Data, It is passed between callbacks and allows the user to validate using each supplied variant.

ValidationPackageDefinition

Constants

THIS_INSTANCE