Module hdk::hash_path::anchor[][src]

The anchor pattern implemented in terms of path::Path

The anchor pattern predates the path crate.

It is conceptually:

  • A two level Path tree
  • Each level of the path is defined as strings not binary data
  • The top level is the “type” and the second level is the “text”
  • The second level is optional as Option<String>

Structs

Anchor

An anchor can only be 1 or 2 levels deep as “type” and “text”.

Constants

ROOT

This is the root of the Path tree.

Functions

anchor

Simple string interface to simple string based paths. a.k.a “the anchor pattern” that predates paths by a few years.

get_anchor

Attempt to get an anchor by its hash. Returns None if the hash doesn’t point to an anchor. We can’t do anything fancy like ensure the anchor if not exists because we only have a hash.

list_anchor_addresses

Returns every entry hash in a vector from the second level of an anchor. Uses the string argument to build the path from the root. Hashes are sorted in the same way that paths sort children.

list_anchor_tags

Old version of holochain that anchors was designed for had two part link tags but now link tags are a single array of bytes, so to get an external interface that is somewhat backwards compatible we need to rebuild the anchors from the paths serialized into the links and then return them.

list_anchor_type_addresses

Returns every entry hash in a vector from the root of an anchor. Hashes are sorted in the same way that paths sort children.