Pfx.marshall
You're seeing just the function
marshall
, go back to Pfx module for more information.
Specs
Returns a representation of pfx
(a Pfx.t/0
-struct) in the form of original
.
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, an address-tuple comes out
which is the first full length prefix in the set represented by pfx
.
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}
iex> marshall(new("1.1.1.1"), {})
{1, 1, 1, 1}