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
//! Gateway event subscription service.
//!
//! This module provides async subscriptions to batman-adv gateway change events.
//! Batman-adv emits uevents when the selected gateway changes in client mode,
//! allowing applications to react to topology changes.
//!
//! # Overview
//!
//! Batman-adv natively emits gateway change events via the kernel's netlink
//! kobject uevent mechanism (NETLINK_KOBJECT_UEVENT). This module abstracts
//! that mechanism through a trait-based service interface.
//!
//! # Backend
//!
//! Gateway events are provided via batman-adv's native
//! `NETLINK_KOBJECT_UEVENT` notifications.
//!
//! # Example
//!
//! ```ignore
//! use batman_robin::Client;
//! use futures::stream::StreamExt;
//!
//! async fn listen_gateways() -> Result<(), Box<dyn std::error::Error>> {
//! let client = Client::new();
//!
//! // Subscribe to gateway events
//! let mut events = client
//! .subscribe_gateway_events(batman_robin::MeshSelector::with_name("bat0"))
//! .await?;
//!
//! while let Some(result) = events.next().await {
//! match result {
//! Ok(event) => println!("Gateway event: {:?}", event),
//! Err(e) => eprintln!("Event error: {}", e),
//! }
//! }
//! Ok(())
//! }
//! ```
use crateError;
use crateGatewayEvent;
use async_trait;
use BoxStream;
/// Service for subscribing to gateway change events.
///
/// Implementations listen to batman-adv kernel uevents and emit
/// GatewayEvent when the selected gateway changes.