Files
rose-ash/next/kernel/nx_cid.erl
giles 9cbf14fe8c
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 6m22s
fed-sx-m1: Step 1b — nx_cid kernel module + 13 canonical CID tests
2026-05-26 19:55:13 +00:00

25 lines
728 B
Erlang

-module(nx_cid).
-export([from_sx/1, to_string/1, from_string/1, equals/2]).
%% The kernel-side CID wrapper. The host BIF `cid:to_string/1` already
%% produces a canonical CIDv1 (raw codec, sha2-256 multihash) over the
%% deterministic textual form of any term (er-format-value); we expose
%% it under the kernel namespace and add the equality + round-trip
%% helpers the rest of the kernel needs.
%%
%% Naming note: the BIF module is `cid`, so we use `nx_cid` to avoid
%% shadowing. Plans/fed-sx-milestone-1.md §Step 1 spells the file as
%% `cid.erl`; the briefing flags Erlang snippets as illustrative.
from_sx(V) ->
cid:to_string(V).
to_string(Cid) ->
Cid.
from_string(S) ->
S.
equals(A, B) ->
A =:= B.