IrohEx.Native (iroh_ex v0.0.14)

Summary

Functions

Create or increment a counter. Returns the new value.

Create a new automerge document, returns doc_id.

Delete a document from memory.

Fork an existing document (create a copy with same history).

Generate a sync message to send to a peer. Returns :not_found if no sync is needed.

Delete a value from a list at index.

List all document IDs.

Get a value from a list at index. Returns :not_found if index doesn't exist.

Insert a value into a list at index.

Push a value to the end of a list.

Load a document from saved binary data.

Get a value from a map at the given path. Returns :not_found if key doesn't exist.

Get all keys from a map.

Put a value in a map at the given path. Path is a list of keys like ["users", "alice", "name"].

Put an object (map, list, or text) at path, returns the object ID. obj_type must be "map", "list", or "text".

Merge another document (as binary) into this one.

Receive and apply a sync message from a peer.

Save document to binary format.

Sync document via gossip (broadcast full document to all peers).

Create a text object at path with optional initial text. Returns the text object ID.

Get document as JSON string for debugging/inspection.

Add binary data as a blob, returns the hash as hex string.

Get a blob by hash, returns the binary data.

List all blob hashes in the store.

Create a new document, returns namespace_id.

Create a new author for documents, returns author_id.

Get an entry from a document - returns content hash.

Get an entry value directly from a document.

List all documents.

Subscribe to a gossip topic with DHT-based auto-discovery. This allows nodes to find each other without exchanging tickets.

Functions

add(a, b)

@spec add(number(), number()) :: {:ok, number()} | {:error, term()}

automerge_counter_get(node, doc_id, path, key)

@spec automerge_counter_get(reference(), binary(), [binary()], binary()) :: integer()

Get counter value.

automerge_counter_increment(node, doc_id, path, key, delta)

@spec automerge_counter_increment(
  reference(),
  binary(),
  [binary()],
  binary(),
  integer()
) :: integer()

Create or increment a counter. Returns the new value.

automerge_create_doc(node)

@spec automerge_create_doc(reference()) :: binary()

Create a new automerge document, returns doc_id.

automerge_delete_doc(node, doc_id)

@spec automerge_delete_doc(reference(), binary()) :: boolean()

Delete a document from memory.

automerge_fork_doc(node, doc_id)

@spec automerge_fork_doc(reference(), binary()) :: binary()

Fork an existing document (create a copy with same history).

automerge_generate_sync_message(node, doc_id, peer_id)

@spec automerge_generate_sync_message(reference(), binary(), binary()) ::
  binary() | :not_found

Generate a sync message to send to a peer. Returns :not_found if no sync is needed.

automerge_list_delete(node, doc_id, path, index)

@spec automerge_list_delete(reference(), binary(), [binary()], non_neg_integer()) ::
  :ok

Delete a value from a list at index.

automerge_list_docs(node)

@spec automerge_list_docs(reference()) :: [binary()]

List all document IDs.

automerge_list_get(node, doc_id, path, index)

@spec automerge_list_get(reference(), binary(), [binary()], non_neg_integer()) ::
  term()

Get a value from a list at index. Returns :not_found if index doesn't exist.

automerge_list_insert(node, doc_id, path, index, value)

@spec automerge_list_insert(
  reference(),
  binary(),
  [binary()],
  non_neg_integer(),
  term()
) :: :ok

Insert a value into a list at index.

automerge_list_length(node, doc_id, path)

@spec automerge_list_length(reference(), binary(), [binary()]) :: non_neg_integer()

Get list length.

automerge_list_push(node, doc_id, path, value)

@spec automerge_list_push(reference(), binary(), [binary()], term()) :: :ok

Push a value to the end of a list.

automerge_load_doc(node, data)

@spec automerge_load_doc(reference(), binary()) :: binary()

Load a document from saved binary data.

automerge_map_delete(node, doc_id, path, key)

@spec automerge_map_delete(reference(), binary(), [binary()], binary()) :: :ok

Delete a key from a map.

automerge_map_get(node, doc_id, path, key)

@spec automerge_map_get(reference(), binary(), [binary()], binary()) :: term()

Get a value from a map at the given path. Returns :not_found if key doesn't exist.

automerge_map_keys(node, doc_id, path)

@spec automerge_map_keys(reference(), binary(), [binary()]) :: [binary()]

Get all keys from a map.

automerge_map_put(node, doc_id, path, key, value)

@spec automerge_map_put(reference(), binary(), [binary()], binary(), term()) :: :ok

Put a value in a map at the given path. Path is a list of keys like ["users", "alice", "name"].

automerge_map_put_object(node, doc_id, path, key, obj_type)

@spec automerge_map_put_object(reference(), binary(), [binary()], binary(), binary()) ::
  binary()

Put an object (map, list, or text) at path, returns the object ID. obj_type must be "map", "list", or "text".

automerge_merge(node, doc_id, other_doc_bytes)

@spec automerge_merge(reference(), binary(), binary()) :: :ok

Merge another document (as binary) into this one.

automerge_receive_sync_message(node, doc_id, peer_id, message)

@spec automerge_receive_sync_message(reference(), binary(), binary(), binary()) :: :ok

Receive and apply a sync message from a peer.

automerge_save_doc(node, doc_id)

@spec automerge_save_doc(reference(), binary()) :: binary()

Save document to binary format.

automerge_sync_via_gossip(node, doc_id)

@spec automerge_sync_via_gossip(reference(), binary()) :: :ok

Sync document via gossip (broadcast full document to all peers).

automerge_text_create(node, doc_id, path, key, initial_text)

@spec automerge_text_create(reference(), binary(), [binary()], binary(), binary()) ::
  binary()

Create a text object at path with optional initial text. Returns the text object ID.

automerge_text_delete(node, doc_id, path, position, length)

@spec automerge_text_delete(
  reference(),
  binary(),
  [binary()],
  non_neg_integer(),
  non_neg_integer()
) ::
  :ok

Delete text at position.

automerge_text_get(node, doc_id, path)

@spec automerge_text_get(reference(), binary(), [binary()]) :: binary()

Get full text content.

automerge_text_insert(node, doc_id, path, position, text)

@spec automerge_text_insert(
  reference(),
  binary(),
  [binary()],
  non_neg_integer(),
  binary()
) :: :ok

Insert text at position.

automerge_to_json(node, doc_id)

@spec automerge_to_json(reference(), binary()) :: binary()

Get document as JSON string for debugging/inspection.

blob_add(node, data)

@spec blob_add(reference(), binary()) :: {:ok, binary()} | {:error, term()}

Add binary data as a blob, returns the hash as hex string.

blob_get(node, hash)

@spec blob_get(reference(), binary()) :: {:ok, binary()} | {:error, term()}

Get a blob by hash, returns the binary data.

blob_list(node)

@spec blob_list(reference()) :: {:ok, [binary()]} | {:error, term()}

List all blob hashes in the store.

broadcast_message(node, topic_str, message)

@spec broadcast_message(reference(), binary(), binary()) ::
  {:ok, reference()} | {:error, term()}

cleanup(node)

@spec cleanup(reference()) :: {:ok, reference()} | {:error, term()}

connect_node(node, ticket)

@spec connect_node(reference(), binary()) :: {:ok, reference()} | {:error, term()}

connect_node_by_pubkey(pubkey)

@spec connect_node_by_pubkey(binary()) :: {:ok, reference()} | {:error, term()}

create_node(pid, node_config)

@spec create_node(pid(), IrohEx.NodeConfig.t()) ::
  {:ok, reference()} | {:error, term()}

create_ticket(node)

@spec create_ticket(reference()) :: {:ok, binary()} | {:error, term()}

disconnect_node(node)

@spec disconnect_node(reference()) :: {:ok} | {:error, term()}

docs_create(node)

@spec docs_create(reference()) :: {:ok, binary()} | {:error, term()}

Create a new document, returns namespace_id.

docs_create_author(node)

@spec docs_create_author(reference()) :: {:ok, binary()} | {:error, term()}

Create a new author for documents, returns author_id.

docs_get_entry(node, namespace_id, author_id, key)

@spec docs_get_entry(reference(), binary(), binary(), binary()) ::
  {:ok, binary()} | {:error, term()}

Get an entry from a document - returns content hash.

docs_get_entry_value(node, namespace_id, author_id, key)

@spec docs_get_entry_value(reference(), binary(), binary(), binary()) ::
  {:ok, binary()} | {:error, term()}

Get an entry value directly from a document.

docs_list(node)

@spec docs_list(reference()) :: {:ok, [binary()]} | {:error, term()}

List all documents.

docs_set_entry(node, namespace_id, author_id, key, value)

@spec docs_set_entry(reference(), binary(), binary(), binary(), binary()) ::
  {:ok, binary()} | {:error, term()}

Set an entry in a document.

gen_node_addr(node)

@spec gen_node_addr(reference()) :: {:ok, binary()} | {:error, term()}

generate_secretkey()

@spec generate_secretkey() :: {:ok, binary()} | {:error, term()}

list_peers(node)

@spec list_peers(reference()) :: {:ok, [binary()]} | {:error, term()}

list_topics(node)

@spec list_topics(reference()) :: {:ok, [binary()]} | {:error, term()}

send_message(node, message)

@spec send_message(reference(), binary()) :: {:ok, reference()} | {:error, term()}

shutdown(node)

@spec shutdown(reference()) :: :ok | {:error, term()}

subscribe_to_topic(node, topic_str, node_ids)

@spec subscribe_to_topic(reference(), binary(), [binary()]) ::
  {:ok, reference()} | {:error, term()}

subscribe_with_auto_discovery(node, topic_name, secret_seed)

@spec subscribe_with_auto_discovery(reference(), binary(), binary() | nil) ::
  {:ok, reference()} | {:error, term()}

Subscribe to a gossip topic with DHT-based auto-discovery. This allows nodes to find each other without exchanging tickets.

Parameters

  • node - The node reference
  • topic_name - The topic name to subscribe to
  • secret_seed - Optional secret seed for key derivation (nil for random)

Returns

  • {:ok, node_ref} on success
  • {:error, term()} on failure

unsubscribe_from_topic(node, topic_str)

@spec unsubscribe_from_topic(reference(), binary()) ::
  {:ok, reference()} | {:error, term()}