Function hdk::entry::get_details

source ·
pub fn get_details<H: Into<AnyDhtHash>>(
    hash: H,
    options: GetOptions,
) -> ExternResult<Option<Details>>
Expand description

Get a record and its details for the entry or action hash passed in. Returns None if the entry/action does not exist. The details returned are a contextual mix of records and action hashes.

Note: The return details will be inferred by the hash type passed in, be careful to pass in the correct hash type for the details you want.

This is implemented in the RecordDetails variants:

Details::Record for an action hash returns:

  • the record for this action hash if it exists
  • all update and delete records that reference that specified action

Details::Entry for an entry hash returns:

  • all creates, updates and delete records that reference that entry hash
  • all update and delete records that reference the records that reference the entry hash

If an action hash is passed in, the action’s record will be returned. If an entry hash is passed in, all the actions and records for that entry are returned. The details returned include relevant creates, updates and deletes for the hash passed in.

Creates are initial action/entry combinations (records) produced by create_entry and cannot reference other actions. Updates and deletes both reference a specific action+entry combination. Updates must reference another create or update action+entry. Deletes must reference a create or update action+entry (nothing can reference a delete).

Full records are returned for direct references to the passed hash. Action hashes are returned for references to references to the passed hash.

Details::Record for an action hash return:

  • the record for this action hash if it exists
  • all update and delete records that reference that specified action

Details::Entry for an entry hash return:

  • all creates, updates and delete records that reference that entry hash
  • all update and delete records that reference the records that reference the entry hash

Note: Entries are just values, so can be referenced by many CRUD actions by many authors. e.g. the number 1 or string “foo” can be referenced by anyone publishing CRUD actions at any time they need to represent 1 or “foo” for a create, update or delete. If you need to disambiguate entry values, provide uniqueness in the entry value such as a unique hash (e.g. current chain head), timestamp (careful about collisions!), or random bytes/uuid (see random_bytes() and the uuid rust crate that supports uuids from bytes).

Note: There are multiple action types that exist and operate entirely outside of CRUD records so they cannot reference or be referenced by CRUD, so are immutable or have their own mutation logic (e.g. link create/delete) and will not be included in get_details results e.g. the DNA itself, links, migrations, etc. However the record will still be returned by get_details if an action hash is passed, these non-entry records will have None as the entry value.