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 CHECK_NODE_ID: bool;
// 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 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,
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.