1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! Protocol version and feature negotiation between peers.
//!
//! When two IPFRS peers connect, they exchange [`ProtocolOffer`] messages to
//! determine the best mutually supported configuration:
//! - The highest protocol version both sides understand
//! - The intersection of supported feature flags
//! - A safe chunk size (minimum of both peers' preferences)
//!
//! ## Example
//!
//! ```rust
//! use ipfrs_network::protocol_negotiator::{
//! NegotiatorConfig, ProtocolFeature, ProtocolNegotiator, NegotiationResult,
//! };
//!
//! let config = NegotiatorConfig::default();
//! let negotiator = ProtocolNegotiator::new(config);
//!
//! let local = negotiator.config.local_offer(
//! "local-peer".to_string(),
//! vec![ProtocolFeature::Encryption, ProtocolFeature::Compression],
//! );
//! let remote = negotiator.config.local_offer(
//! "remote-peer".to_string(),
//! vec![ProtocolFeature::Encryption, ProtocolFeature::Multiplexing],
//! );
//!
//! match negotiator.negotiate(&local, &remote) {
//! NegotiationResult::Agreed { version, features, chunk_size } => {
//! assert_eq!(version, 3);
//! assert_eq!(features, vec![ProtocolFeature::Encryption]);
//! assert_eq!(chunk_size, 65536);
//! }
//! other => panic!("unexpected result: {:?}", other),
//! }
//! ```
// Re-export all types
pub use *;