Module erlang

Module erlang 

Source
Expand description

Erlang node connectivity and RPC communication.

This module provides functionality to connect to Erlang nodes using the distributed Erlang protocol and make RPC calls for messaging operations, including persistent message history loading.

§Architecture

The module uses erl_dist for the distributed Erlang protocol and erl_rpc for making RPC calls. The connection is established asynchronously and the RPC client runs in a background task.

§Message History

The module provides three methods for loading message history:

  • load_recent_messages() - Load the most recent N messages
  • load_messages_before() - Load older messages before a timestamp (for scrolling up)
  • load_messages_range() - Load messages within a time range

Messages are retrieved from the Erlang backend’s SQLite database via RPC calls to cryptic_rpc module, which decrypts and returns them as structured data.

§Examples

use cryptic_tui::erlang::ErlangConnection;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create connection
    let conn = ErlangConnection::new(
        "admin@localhost".to_string(),
        "mycookie".to_string()
    );

    // Connect to remote node
    conn.connect().await?;

    // Load recent message history
    let messages = conn.load_recent_messages("alice", 50).await?;
    println!("Loaded {} messages", messages.len());

    Ok(())
}

Structs§

ErlangConnection
Manages a connection to a remote Erlang node.

Enums§

ConnectionStatus
Connection status to an Erlang node.

Functions§

extract_binary 🔒
Extract a string from a binary term
extract_integer 🔒
Extract an integer from a term
parse_message_history 🔒
Parse message history from Erlang RPC response.