Pfx.marshall
You're seeing just the function
marshall
, go back to Pfx module for more information.
Specs
Given a t.Pfx.t/0
prefix, try to represent it in its original form.
The exact original is not required, the pfx
is transformed by the shape of
the original
argument: string vs two-element tuple vs tuple. If none of
the three shapes match, the pfx
is returned unchanged.
This is used to allow results to be the same shape as their (first) argument
that needed to turn into a Pfx.t/0
for some calculation.
Note that when turning a prefix into a address-tuple, the first full length member comes out as an address.
Examples
# original is a string
iex> marshall(%Pfx{bits: <<1, 1, 1>>, maxlen: 32}, "any string really")
"1.1.1.0/24"
# original is any two-element tuple
iex> marshall(%Pfx{bits: <<1, 1, 1>>, maxlen: 32}, {0,0})
{{1, 1, 1, 0}, 24}
# original is any other tuple, actually turns prefix into this-network address
iex> marshall(%Pfx{bits: <<1, 1, 1>>, maxlen: 32}, {})
{1, 1, 1, 0}
# original is a Pfx struct
iex> marshall(%Pfx{bits: <<1, 1, 1>>, maxlen: 32}, %Pfx{bits: <<>>, maxlen: 0})
%Pfx{bits: <<1, 1, 1>>, maxlen: 32}