cuprate_p2p_core

Trait NetZoneAddress

Source
pub trait NetZoneAddress:
    TryFrom<NetworkAddress, Error = NetworkAddressIncorrectZone>
    + Into<NetworkAddress>
    + Display
    + Hash
    + Eq
    + Copy
    + Send
    + Sync
    + Unpin
    + 'static {
    type BanID: Debug + Hash + Eq + Clone + Copy + Send + 'static;

    // Required methods
    fn set_port(&mut self, port: u16);
    fn make_canonical(&mut self);
    fn ban_id(&self) -> Self::BanID;
    fn should_add_to_peer_list(&self) -> bool;
}
Expand description

An address on a specific NetworkZone.

Required Associated Types§

Source

type BanID: Debug + Hash + Eq + Clone + Copy + Send + 'static

Cuprate needs to be able to ban peers by IP addresses and not just by SocketAddr as that include the port, to be able to facilitate this network addresses must have a ban ID which for hidden services could just be the address it self but for clear net addresses will be the IP address.

  • TODO: IP zone banning?
  • TODO: rename this to Host.

Required Methods§

Source

fn set_port(&mut self, port: u16)

Changes the port of this address to port.

Source

fn make_canonical(&mut self)

Turns this address into its canonical form.

Source

fn ban_id(&self) -> Self::BanID

Returns the Self::BanID for this address.

Source

fn should_add_to_peer_list(&self) -> bool

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 NetZoneAddress for SocketAddr

Source§

type BanID = IpAddr

Source§

fn set_port(&mut self, port: u16)

Source§

fn ban_id(&self) -> Self::BanID

Source§

fn make_canonical(&mut self)

Source§

fn should_add_to_peer_list(&self) -> bool

Implementors§