View Source NostrBasics.Event.Id (NostrBasics v0.0.13)
Event id conversion functions
Link to this section Summary
Functions
Converts a bech32 event id into its binary format
Converts a bech32 event id into its binary format
Converts an event binary id into a bech32 format
Does its best to convert any event id format to binary, issues an error if it can't
Converts any type of event id into a hex format
Converts a bech32 event id into a hex string format
Link to this section Functions
Converts a bech32 event id into its binary format
examples
Examples
iex> "note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
...> |> NostrBasics.Event.Id.from_bech32
{:ok, "note", <<0x2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2::256>>}
@spec from_bech32!(binary()) :: <<_::256>>
Converts a bech32 event id into its binary format
examples
Examples
iex> "note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
...> |> NostrBasics.Event.Id.from_bech32!
<<0x2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2::256>>
Converts an event binary id into a bech32 format
examples
Examples
iex> <<0x2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2::256>>
...> |> NostrBasics.Event.Id.to_bech32("note")
"note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
iex> "2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2"
...> |> NostrBasics.Event.Id.to_bech32("note")
"note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
@spec to_binary(<<_::256>> | String.t() | list()) :: {:ok, <<_::256>>} | {:ok, [<<_::256>>]} | {:error, String.t()}
Does its best to convert any event id format to binary, issues an error if it can't
examples
Examples
iex> "note1qkjgra6cm5ms6m88kqdapfjnxm8q50lcurevtpvm4f6pfs8j5sxq90f098"
...> |> NostrBasics.Event.Id.to_binary()
{ :ok, <<0x05a481f758dd370d6ce7b01bd0a65336ce0a3ff8e0f2c5859baa7414c0f2a40c::256>> }
iex> [<<0x73b0011409b488352545775d6b24b4de47ff8ff29998d7d61cdee7f9a9a208ee::256>>]
...> |> NostrBasics.Event.Id.to_binary()
{ :ok, [<<0x73b0011409b488352545775d6b24b4de47ff8ff29998d7d61cdee7f9a9a208ee::256>>]}
Converts any type of event id into a hex format
examples
Examples
iex> <<0x2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2::256>>
...> |> NostrBasics.Event.Id.to_hex()
{:ok, nil, "2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2"}
iex> "note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
...> |> NostrBasics.Event.Id.to_hex
{:ok, "note", "2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2"}
@spec to_hex!(binary()) :: <<_::512>>
Converts a bech32 event id into a hex string format
examples
Examples
iex> "note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
...> |> NostrBasics.Event.Id.to_hex!
"2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2"