Trait routing::Xorable [] [src]

pub trait Xorable: Ord + Sized {
    fn common_prefix(&self, other: &Self) -> usize;
fn cmp_distance(&self, lhs: &Self, rhs: &Self) -> Ordering;
fn bit(&self, i: usize) -> bool;
fn differs_in_bit(&self, other: &Self, i: usize) -> bool;
fn with_flipped_bit(self, i: usize) -> Self;
fn with_bit(self, i: usize, bit: bool) -> Self;
fn binary(&self) -> String;
fn debug_binary(&self) -> String;
fn set_remaining(self, n: usize, val: bool) -> Self;
fn from_hash<T: AsRef<[u8]>>(hash: T) -> Self; fn bit_len() -> usize { ... } }

A sequence of bits, as a point in XOR space.

These are considered points in a space with the XOR metric, and need to implement the functionality required by RoutingTable to use them as node names.

Required Methods

Returns the length of the common prefix with the other name; e. g. the when other = 11110000 and self = 11111111 this is 4.

Compares the distance of the arguments to self. Returns Less if lhs is closer, Greater if rhs is closer, and Equal if lhs == rhs. (The XOR distance can only be equal if the arguments are equal.)

Returns true if the i-th bit is 1.

Returns true if the i-th bit of other has a different value to the i-th bit of self.

Returns a copy of self, with the index-th bit flipped.

If index exceeds the number of bits in self, an unmodified copy of self is returned.

Returns a copy of self, with the index-th bit set to bit.

If index exceeds the number of bits in self, an unmodified copy of self is returned.

Returns a binary format string, with leading zero bits included.

Returns a binary debug format string of ????????...????????

Returns a copy of self with first n bits preserved, and remaining bits set to 0 (val == false) or 1 (val == true).

Returns a Self instance constructed from an array of bytes.

Provided Methods

Returns the number of bits in Self.

Implementations on Foreign Types

impl Xorable for [u8; 32]
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl Xorable for [u8; 16]
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl Xorable for [u8; 8]
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl Xorable for [u8; 4]
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl Xorable for usize
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl Xorable for u64
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl Xorable for u32
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl Xorable for u16
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl Xorable for u8
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Implementors