macula_core_types (macula v0.20.5)
View SourceCore type definitions and encoding/decoding for Macula. Provides fundamental types like node IDs, realm IDs, and addresses.
Summary
Functions
Decode binary address format to {IP, Port} tuple.
Encode an IP address and port to binary format. Format: - 1 byte: IP version (4 or 6) - 4 or 16 bytes: IP address - 2 bytes: port (big-endian)
Generate a unique node ID. Uses cryptographically strong random bytes for uniqueness.
Generate a deterministic realm ID from a realm name. Same name always produces the same ID (uses SHA-256 hash).
Types
-type address() :: {ip_address(), port_number()}.
-type ip_address() :: inet:ip_address().
-type node_id() :: binary().
32-byte unique node identifier
-type port_number() :: inet:port_number().
-type realm_id() :: binary().
32-byte realm identifier
Functions
Decode binary address format to {IP, Port} tuple.
Encode an IP address and port to binary format. Format: - 1 byte: IP version (4 or 6) - 4 or 16 bytes: IP address - 2 bytes: port (big-endian)
-spec node_id() -> node_id().
Generate a unique node ID. Uses cryptographically strong random bytes for uniqueness.
Generate a deterministic realm ID from a realm name. Same name always produces the same ID (uses SHA-256 hash).