Pfx.slice

You're seeing just the function slice, go back to Pfx module for more information.

Specs

slice(t(), non_neg_integer()) :: [t()] | PfxError.t()

Slice a prefix into a list of smaller pieces, each newlen bits long.

The given newlen must be larger than or equal to the prefix' current bit length, else it is considered an error.

Examples

# break out the /26's in a /24
iex> new(<<10, 11, 12>>, 32)|> slice(26)
[
  %Pfx{bits: <<10, 11, 12, 0::size(2)>>, maxlen: 32},
  %Pfx{bits: <<10, 11, 12, 1::size(2)>>, maxlen: 32},
  %Pfx{bits: <<10, 11, 12, 2::size(2)>>, maxlen: 32},
  %Pfx{bits: <<10, 11, 12, 3::size(2)>>, maxlen: 32}
]