Struct routing::XorName [] [src]

pub struct XorName(pub [u8; 32]);

A XOR_NAME_BITS-bit number, viewed as a point in XOR space.

This wraps an array of XOR_NAME_LEN bytes, i. e. a number between 0 and 2XOR_NAME_BITS - 1.

XOR space is the space of these numbers, with the XOR metric as a notion of distance, i. e. the points with IDs x and y are considered to have distance x xor y.

Methods

impl XorName
[src]

[src]

Hex-encode the XorName as a String.

[src]

Returns the number of bits in which self differs from other.

[src]

Hex-decode a XorName from a &str.

[src]

Returns true if lhs is closer to self than rhs.

Equivalently, this returns true if in the most significant bit where lhs and rhs disagree, lhs agrees with self.

[src]

Returns true if lhs is closer to self than rhs, or lhs == rhs.

Trait Implementations

impl Eq for XorName
[src]

impl Copy for XorName
[src]

impl Clone for XorName
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for XorName
[src]

[src]

Returns the "default value" for a type. Read more

impl Hash for XorName
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Ord for XorName
[src]

[src]

This method returns an Ordering between self and other. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

impl PartialEq for XorName
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl PartialOrd for XorName
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Xorable for XorName
[src]

[src]

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

[src]

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.) Read more

[src]

Returns true if the i-th bit is 1.

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

Returns a Self instance constructed from an array of bytes.

[src]

Returns the number of bits in Self.

impl Debug for XorName
[src]

[src]

Formats the value using the given formatter.

impl Display for XorName
[src]

[src]

Formats the value using the given formatter. Read more

impl Binary for XorName
[src]

[src]

Formats the value using the given formatter.

impl Rand for XorName
[src]

[src]

Generates a random instance of this type using the specified source of randomness. Read more

impl Index<Range<usize>> for XorName
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl Index<RangeTo<usize>> for XorName
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl Index<RangeFrom<usize>> for XorName
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl Index<RangeFull> for XorName
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl Not for XorName
[src]

The resulting type after applying the ! operator.

[src]

Performs the unary ! operation.

impl Sub for XorName
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a> Sub for &'a XorName
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl Div<u32> for XorName
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<'a> Div<&'a u32> for &'a XorName
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.