8 releases (5 breaking)

0.6.0 Jun 16, 2023
0.5.1 Apr 3, 2022
0.4.0 Apr 2, 2022
0.3.0 Mar 23, 2022
0.1.0 Dec 20, 2016

#386 in Asynchronous

Download history 123/week @ 2023-12-15 8/week @ 2023-12-22 34/week @ 2023-12-29 33/week @ 2024-01-05 38/week @ 2024-01-12 84/week @ 2024-01-19 88/week @ 2024-01-26 81/week @ 2024-02-02 229/week @ 2024-02-09 101/week @ 2024-02-16 89/week @ 2024-02-23 120/week @ 2024-03-01 130/week @ 2024-03-08 165/week @ 2024-03-15 91/week @ 2024-03-22 59/week @ 2024-03-29

469 downloads per month
Used in 2 crates

MIT license

125KB
3K SLoC

erl_dist

erl_dist Documentation Actions Status Coverage Status License: MIT

Rust Implementation of Erlang Distribution Protocol.

The distribution protocol is used to communicate with distributed erlang nodes.

Examples

Gets a node entry from EPMD:

use erl_dist::epmd::{DEFAULT_EPMD_PORT, EpmdClient};

// Connect to the local EPMD.
let connection = TcpStream::connect(("localhost", DEFAULT_EPMD_PORT)).await?;
let client = EpmdClient::new(connection);

// Get the information of a node.
let node_name = "foo";
if let Some(node) = client.get_node(node_name).await? {
    println!("Found: {:?}", node);
} else {
    println!("Not found");
}

Sends a message to an Erlang node:

use erl_dist::LOWEST_DISTRIBUTION_PROTOCOL_VERSION;
use erl_dist::node::{Creation, LocalNode};
use erl_dist::handshake::ClientSideHandshake;
use erl_dist::term::{Atom, Pid};
use erl_dist::message::{channel, Message};

// Connect to a peer node.
let peer_host = "localhost";
let peer_port = 7483;  // NOTE: Usually, port number is retrieved from EPMD.
let connection = TcpStream::connect((peer_host, peer_port)).await?;

// Local node information.
let creation = Creation::random();
let local_node = LocalNode::new("foo@localhost".parse()?, creation);

// Do handshake.
let mut handshake = ClientSideHandshake::new(connection, local_node.clone(), "cookie");
let _status = handshake.execute_send_name(LOWEST_DISTRIBUTION_PROTOCOL_VERSION).await?;
let (connection, peer_node) = handshake.execute_rest(true).await?;

// Create a channel.
let capability_flags = local_node.flags & peer_node.flags;
let (mut tx, _) = channel(connection, capability_flags);

// Send a message.
let from_pid = Pid::new(local_node.name.to_string(), 0, 0, local_node.creation.get());
let to_name = Atom::from("bar");
let msg = Message::reg_send(from_pid, to_name, Atom::from("hello").into());
tx.send(msg).await?;

Example commands:

  • erl_rpc: Erlang RPC client for Rust
  • erldash: Terminal-based Erlang dashboard

Dependencies

~2.4–3MB
~65K SLoC