[][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!

Re-exports

pub extern crate serde;
pub extern crate holochain_core_types;
pub extern crate holochain_dna;
pub extern crate holochain_wasm_utils;

Modules

entry_definition
error
global_fns
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
meta

Macros

define_zome

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

entry

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

Structs

AGENT_ADDRESS

The hash of your public key. This is your node address on the DHT. It can be used for node-to-node messaging with send and receive functions.

AGENT_ID_STR

The identity string used when the chain was first initialized.

AGENT_INITIAL_HASH

The hash of the first identity entry on your chain (The second entry on your chain). This is your peer's identity on the DHT.

DNA_HASH

The hash of the DNA the Zome is embedded within. This is often useful as a fixed value that is known by all participants running the DNA.

DNA_NAME

The name property as taken from the DNA.

EntryStatus
EntryValidationArgs
GetEntryMask
ValidationData
ValidationPackage

Enums

BundleOnClose
EntryAction
EntryLifecycle
LinkAction
ValidationPackageDefinition

Functions

call

Call an exposed function from another zome. Arguments for the called function are passed as serde_json::Value. Returns the value that's returned by the given function as a json str.

close_bundle

Not Yet Available

commit_entry

Attempts to commit an entry to your local source chain. The entry will have to pass the defined validation rules for that entry type. If the entry type is defined as public, will also publish the entry to the DHT. Returns either an address of the committed entry as a string, or an error.

debug

Prints a string through the stdout of the running service, and also writes that string to the logger in the execution context

get_entry

Retrieves an entry from the local chain or the DHT, by looking it up using its address.

get_entry_result

Retrieves an entry and meta data from the local chain or the DHT, by looking it up using its address, and a the full options to specify exactly what data to return

get_links

Consumes two values, the first of which is the address of an entry, base, and the second of which is a string, tag, used to describe the relationship between the base and other entries you wish to lookup. Returns a list of addresses of other entries which matched as being linked by the given tag. Links are created in the first place using the Zome API function link_entries. Once you have the addresses, there is a good likelihood that you will wish to call get_entry for each of them.

hash_entry

Reconstructs an address of the given entry data. This is the same value that would be returned if entry_type_name and entry_value were passed to the commit_entry function and by which it would be retrievable from the DHT using get_entry. This is often used to reconstruct an address of a base argument when calling get_links.

link_entries

Consumes three values, two of which are the addresses of entries, and one of which is a string that defines a relationship between them, called a tag. Later, lists of entries can be looked up by using get_links. Entries can only be looked up in the direction from the base, which is the first argument, to the target.

property

Not Yet Available

query

Returns a list of entries from your local source chain, that match a given type.

remove_entry

Not Yet Available

send

Not Yet Available

sign

Not Yet Available

start_bundle

Not Yet Available

update_agent

Not Yet Available

update_entry

Not Yet Available

verify_signature

Not Yet Available