Trait cuprate_p2p_core::NetworkZone
source · pub trait NetworkZone:
Clone
+ Copy
+ Send
+ 'static {
type Addr: NetZoneAddress;
type Stream: Stream<Item = Result<Message, BucketError>> + Unpin + Send + 'static;
type Sink: Sink<LevinMessage<Message>, Error = BucketError> + Unpin + Send + 'static;
type Listener: Stream<Item = Result<(Option<Self::Addr>, Self::Stream, Self::Sink), Error>> + Send + 'static;
type ServerCfg: Clone + Debug + Send + 'static;
const NAME: &'static str;
const ALLOW_SYNC: bool;
const DANDELION_PP: bool;
const CHECK_NODE_ID: bool;
const SEEDS: &'static [Self::Addr];
// Required methods
fn connect_to_peer<'async_trait>(
addr: Self::Addr,
) -> Pin<Box<dyn Future<Output = Result<(Self::Stream, Self::Sink), Error>> + Send + 'async_trait>>
where Self: 'async_trait;
fn incoming_connection_listener<'async_trait>(
config: Self::ServerCfg,
port: u16,
) -> Pin<Box<dyn Future<Output = Result<Self::Listener, Error>> + Send + 'async_trait>>
where Self: 'async_trait;
}
Expand description
An abstraction over a network zone (tor/i2p/clear)
Required Associated Constants§
sourceconst ALLOW_SYNC: bool
const ALLOW_SYNC: bool
Allow syncing over this network.
Not recommended for anonymity networks.
sourceconst DANDELION_PP: bool
const DANDELION_PP: bool
Enable dandelion++ for this network.
This is unneeded on anonymity networks.
sourceconst CHECK_NODE_ID: bool
const CHECK_NODE_ID: bool
Check if our node ID matches the incoming peers node ID for this network.
This has privacy implications on an anonymity network if true so should be set to false.
Required Associated Types§
sourcetype Addr: NetZoneAddress
type Addr: NetZoneAddress
The address type of this network.
sourcetype Stream: Stream<Item = Result<Message, BucketError>> + Unpin + Send + 'static
type Stream: Stream<Item = Result<Message, BucketError>> + Unpin + Send + 'static
The stream (incoming data) type for this network.
sourcetype Sink: Sink<LevinMessage<Message>, Error = BucketError> + Unpin + Send + 'static
type Sink: Sink<LevinMessage<Message>, Error = BucketError> + Unpin + Send + 'static
The sink (outgoing data) type for this network.
Required Methods§
sourcefn connect_to_peer<'async_trait>(
addr: Self::Addr,
) -> Pin<Box<dyn Future<Output = Result<(Self::Stream, Self::Sink), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
fn connect_to_peer<'async_trait>(
addr: Self::Addr,
) -> Pin<Box<dyn Future<Output = Result<(Self::Stream, Self::Sink), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
Connects to a peer with the given address.
This does not complete a handshake with the peer, to do that see the crate docs.
Returns the Self::Stream
and Self::Sink
to send messages to the peer.
fn incoming_connection_listener<'async_trait>(
config: Self::ServerCfg,
port: u16,
) -> Pin<Box<dyn Future<Output = Result<Self::Listener, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
Object Safety§
This trait is not object safe.