[−][src]Function cjdns_core::splice::splice
pub fn splice<L: LabelBits>(
labels: &[RoutingLabel<L>]
) -> Result<RoutingLabel<L>>
This function takes one or more RoutingLabel
s and splices them to create a resulting label.
If you have a peer at 0000.0000.0000.0013
and he has a peer at 0000.0000.0000.0015
which you
want to reach, you can splice a label for reaching him as in example below.
Remember that the arguments should be read right to left, the first hop is the furthest to the right in the splice function.
If the result of the splicing is too long to fit in a label (LabelBits<T>::MAX_PAYLOAD_BITS
bits)
then it will return Err(Error::LabelTooLong)
.
let result = splice(&[l("0000.0000.0000.0015"), l("0000.0000.0000.0013")]); assert_eq!(result, Ok(l("0000.0000.0000.0153")));
Splice only works to splice a route if the return route is the same size or smaller. If the return
route is larger then the smaller director in the path must be re-encoded to be the same size as
the return path director. build_label()
will take care of this automatically.