NodeIdType

Trait NodeIdType 

Source
pub trait NodeIdType: Clone {
Show 13 methods // Required methods fn random() -> u32; fn segment(&self) -> NodeSegment; fn distance(&self, other: &u32) -> u32; fn distance_bits(&self, other: &u32) -> u8; fn bucket_index(&self) -> u8; fn build(geo1: u8, geo2: u8, group: u8, index: u8) -> Self; fn build2(zone_id: u16, group: u8, index: u8) -> Self; fn layer(&self, index: u8) -> u8; fn geo1(&self) -> u8; fn geo2(&self) -> u8; fn group(&self) -> u8; fn index(&self) -> u8; fn eq_util_layer(&self, other: &Self) -> u8;
}

Required Methods§

Source

fn random() -> u32

Generates a random NodeId.

Source

fn segment(&self) -> NodeSegment

Returns the segment of the node ID.

Source

fn distance(&self, other: &u32) -> u32

Calculates the distance between two NodeIds.

Source

fn distance_bits(&self, other: &u32) -> u8

Calculates the distance in bits between two NodeIds.

§Arguments
  • other - The other NodeId to calculate the distance to.
§Returns

The distance in bits between the two NodeIds.

Source

fn bucket_index(&self) -> u8

Returns the index of the bucket that this node ID belongs to.

Source

fn build(geo1: u8, geo2: u8, group: u8, index: u8) -> Self

Builds a new NodeId with the given geographic location, group, and index.

§Arguments
  • geo1 - The first geographic location byte.
  • geo2 - The second geographic location byte.
  • group - The group byte.
  • index - The index byte.
Source

fn build2(zone_id: u16, group: u8, index: u8) -> Self

Builds a NodeId from a zone ID, group, and index.

Source

fn layer(&self, index: u8) -> u8

Returns the value of the layer of the node at the given index.

Source

fn geo1(&self) -> u8

Returns the first geographic location byte.

Source

fn geo2(&self) -> u8

Returns the second geographic location byte.

Source

fn group(&self) -> u8

Returns the group byte.

Source

fn index(&self) -> u8

Returns the index byte.

Source

fn eq_util_layer(&self, other: &Self) -> u8

Returns the number of layers that the two NodeIds are equal up to.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl NodeIdType for u32

Source§

fn random() -> u32

Source§

fn segment(&self) -> NodeSegment

Source§

fn distance(&self, other: &u32) -> u32

Source§

fn distance_bits(&self, other: &u32) -> u8

Source§

fn bucket_index(&self) -> u8

Source§

fn layer(&self, index: u8) -> u8

Source§

fn build(geo1: u8, geo2: u8, group: u8, index: u8) -> u32

Source§

fn build2(zone_id: u16, group: u8, index: u8) -> u32

Source§

fn geo1(&self) -> u8

Source§

fn geo2(&self) -> u8

Source§

fn group(&self) -> u8

Source§

fn index(&self) -> u8

Source§

fn eq_util_layer(&self, other: &u32) -> u8

Implementors§