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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Connection builders for different network types.
//!
//! This module provides functions to construct NetworkManager connection settings
//! dictionaries for various connection types. These settings are used with
//! NetworkManager's D-Bus API to create and activate connections.
//!
//! # Available Builders
//!
//! - [`wifi`] - WiFi connection builders (WPA-PSK, WPA-EAP, Open)
//! - [`vpn`] - VPN connection builders (WireGuard)
//! - Ethernet builders (via [`build_ethernet_connection`])
//!
//! # When to Use These
//!
//! Most users should use the high-level [`NetworkManager`](crate::NetworkManager) API
//! instead of calling these builders directly. These are exposed for advanced use cases
//! where you need fine-grained control over connection settings.
//!
//! # Examples
//!
//! ```ignore
//! use nmrs::builders::{build_wifi_connection, build_wireguard_connection, build_ethernet_connection};
//! use nmrs::{WifiSecurity, ConnectionOptions, VpnCredentials, VpnType, WireGuardPeer};
//!
//! let opts = ConnectionOptions {
//! autoconnect: true,
//! autoconnect_priority: Some(10),
//! autoconnect_retries: Some(3),
//! };
//!
//! // Build WiFi connection settings
//! let wifi_settings = build_wifi_connection(
//! "MyNetwork",
//! &WifiSecurity::WpaPsk { psk: "password".into() },
//! &opts
//! );
//!
//! // Build Ethernet connection settings
//! let eth_settings = build_ethernet_connection("eth0", &opts);
//! // Build WireGuard VPN connection settings
//! let opts = ConnectionOptions {
//! autoconnect: true,
//! autoconnect_priority: Some(10),
//! autoconnect_retries: Some(3),
//! };
//!
//! let creds = VpnCredentials {
//! vpn_type: VpnType::WireGuard,
//! name: "MyVPN".into(),
//! gateway: "vpn.example.com:51820".into(),
//! private_key: "YBk6X3pP8KjKz7+HFWzVHNqL3qTZq8hX9VxFQJ4zVmM=".into(),
//! address: "10.0.0.2/24".into(),
//! peers: vec![WireGuardPeer {
//! public_key: "HIgo9xNzJMWLKAShlKl6/bUT1VI9Q0SDBXGtLXkPFXc=".into(),
//! gateway: "vpn.example.com:51820".into(),
//! allowed_ips: vec!["0.0.0.0/0".into()],
//! preshared_key: None,
//! persistent_keepalive: Some(25),
//! }],
//! dns: None,
//! mtu: None,
//! uuid: None,
//! };
//!
//! let vpn_settings = build_wireguard_connection(&creds, &opts).unwrap();
//! ```
//!
//! These settings can then be passed to NetworkManager's
//! `AddConnection` or `AddAndActivateConnection` D-Bus methods.
// Re-export core builder types
pub use ;
pub use ;
pub use WireGuardBuilder;
// Re-export builder functions for convenience
pub use build_bluetooth_connection;
pub use build_wireguard_connection;
pub use ;