Struct comm::address::Address
[−]
[src]
pub struct Address { /* fields omitted */ }An Address can be used to address anything that is Addressable. Nodes, for example, have
an Address. Every client::messages::TextMessage has an Address as well.
Methods
impl Address[src]
pub fn for_content(content: &str) -> Address[src]
Hashes content into an Address. Current implementation is to take the SHA1 digest of
content, but this is subject to change and should not be depended on.
Example
use comm::address; let addr = address::Address::for_content("alep"); let addr_from_str = address::Address::from_str("44751799925b964a00bae3863cc4236f9bb8d519").unwrap(); assert_eq!(addr, addr_from_str);
pub fn from_numeric(numeric: BigUint) -> Address[src]
Creates an Address from its numeric representation. Useful for randomly generating
Addresses within a range.
pub fn from_str(string: &str) -> Result<Address, FromHexError>[src]
Creates a Address from its hexidecimal string representation. string must be
hexidecimal or an Err will be returned.
pub fn null() -> Address[src]
The null Address. Use to address "nothing." No Node, message, or any Addressable
thing should ever reside at the null address. It's useful for bootstrapping a
network::Network when one does not know the address of any peers, but has connection
details to them such as an IP address and port.
pub fn random(min: &BigUint, max: &BigUint) -> Address[src]
Randomly generates an Address within the address space between min and max. Useful
for refreshing a NodeBucket by performing a find node operation on a random address
within its range.
pub fn as_numeric(&self) -> BigUint[src]
The numeric representation of an Address. Useful for partitioning the Nodes in a
NodeBucket into two new buckets.
pub fn distance_from(&self, other: &Self) -> BigUint[src]
The address space distance of self from other. Computed as the XOR of their numeric
representations.
pub fn to_str(&self) -> String[src]
The string representation of an Address. Useful for displaying, exporting outside of
Rust, serializing into a protobuf, etc.
TODO: this may be poorly named, breaking the to_string convention set by
&str::to_string. It's probably wiser to impl ToString.
Trait Implementations
impl Clone for Address[src]
fn clone(&self) -> Address[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Copy for Address[src]
impl Eq for Address[src]
impl Hash for Address[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl PartialEq for Address[src]
fn eq(&self, __arg_0: &Address) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &Address) -> bool[src]
This method tests for !=.
impl Debug for Address[src]
fn fmt(&self, f: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more