[][src]Struct tari_comms::peer_manager::node_id::NodeId

pub struct NodeId(_);

A Node Identity is used as a unique identifier for a node in the Tari communications network.

Implementations

impl NodeId[src]

pub fn new() -> Self[src]

Construct a new node id on the origin

pub fn from_key<K: ByteArray>(key: &K) -> Result<Self, NodeIdError>[src]

Derive a node id from a public key: node_id=hash(public_key)

pub fn distance(&self, node_id: &NodeId) -> NodeDistance[src]

Calculate the distance between the current node id and the provided node id using the XOR metric

pub fn closest_indices(&self, node_ids: &[NodeId], k: usize) -> Vec<usize>[src]

Find and return the indices of the K nearest neighbours from the provided node id list

pub fn closest(&self, node_ids: &[NodeId], k: usize) -> Vec<NodeId>[src]

Find and return the node ids of the K nearest neighbours from the provided node id list

pub fn into_inner(self) -> [u8; 13][src]

pub fn short_str(&self) -> String[src]

Trait Implementations

impl AsRef<[u8]> for NodeId[src]

impl ByteArray for NodeId[src]

fn from_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError>[src]

Try and convert the given byte array to a NodeId. Any failures (incorrect array length, implementation-specific checks, etc) return a ByteArrayError.

fn as_bytes(&self) -> &[u8]

Notable traits for &'_ mut [u8]

impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
[src]

Return the NodeId as a byte array

impl Clone for NodeId[src]

impl Debug for NodeId[src]

impl Default for NodeId[src]

impl<'de> Deserialize<'de> for NodeId[src]

impl Display for NodeId[src]

impl Eq for NodeId[src]

impl Hash for NodeId[src]

fn hash<H: Hasher>(&self, state: &mut H)[src]

Require the implementation of the Hash trait for Hashmaps

impl Ord for NodeId[src]

impl PartialEq<NodeId> for NodeId[src]

impl PartialOrd<NodeId> for NodeId[src]

impl Serialize for NodeId[src]

impl StructuralEq for NodeId[src]

impl<'_> TryFrom<&'_ [u8]> for NodeId[src]

type Error = NodeIdError

The type returned in the event of a conversion error.

fn try_from(elements: &[u8]) -> Result<Self, Self::Error>[src]

Construct a node id from 32 bytes

Auto Trait Implementations

impl RefUnwindSafe for NodeId

impl Send for NodeId

impl Sync for NodeId

impl Unpin for NodeId

impl UnwindSafe for NodeId

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> Cast<U> for T where
    U: FromCast<T>, 

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized
[src]

impl<'a, T> DefaultFeatures<'a> for T where
    T: 'a + Clone + Send + Sync

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> FromBits<T> for T

impl<T> FromCast<T> for T

impl<T> Hex for T where
    T: ByteArray, 

type T = T

impl<T> InitializableFromZeroed for T where
    T: Default
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> IntoBits<U> for T where
    U: FromBits<T>, 

impl<T> MessageFormat for T where
    T: DeserializeOwned + Serialize

impl<'a, T> NonSyncFeatures<'a> for T where
    T: 'a + Clone

impl<T> SafeBorrow<T> for T where
    T: ?Sized

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,