pub struct GatewayEvent {
pub timestamp: SystemTime,
pub meshif: u32,
pub meshif_name: String,
pub action: GatewayEventAction,
pub gateway_mac: Option<MacAddr>,
}Expand description
Gateway change event emitted by batman-adv kernel module.
When a batman-adv node is in gateway client mode, it emits uevents when the selected gateway changes. Applications can subscribe to these events to perform actions like starting/renewing DHCP leases.
§Examples
ⓘ
let client = batman_robin::Client::new();
let mut events = client
.subscribe_gateway_events(batman_robin::MeshSelector::with_name("bat0"))
.await?;
while let Some(event) = events.next().await {
match event?.action {
GatewayEventAction::Add => println!("Gateway selected: {:?}", event?.gateway_mac),
GatewayEventAction::Change => println!("Better gateway found"),
GatewayEventAction::Delete => println!("Gateway lost"),
}
}Fields§
§timestamp: SystemTimeTimestamp when the event was received
meshif: u32Mesh interface index (e.g. from if_nametoindex("bat0"))
meshif_name: StringMesh interface name (e.g. “bat0”)
action: GatewayEventActionType of gateway change event
gateway_mac: Option<MacAddr>MAC address of the selected gateway (present for ADD/CHANGE, absent for DELETE)
Implementations§
Source§impl GatewayEvent
impl GatewayEvent
Sourcepub fn new(
meshif: u32,
meshif_name: String,
action: GatewayEventAction,
gateway_mac: Option<MacAddr>,
) -> Self
pub fn new( meshif: u32, meshif_name: String, action: GatewayEventAction, gateway_mac: Option<MacAddr>, ) -> Self
Create a new gateway event
Sourcepub fn has_gateway(&self) -> bool
pub fn has_gateway(&self) -> bool
Check if this event has a valid associated gateway MAC
Trait Implementations§
Source§impl Clone for GatewayEvent
impl Clone for GatewayEvent
Source§fn clone(&self) -> GatewayEvent
fn clone(&self) -> GatewayEvent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GatewayEvent
impl Debug for GatewayEvent
impl Eq for GatewayEvent
Source§impl PartialEq for GatewayEvent
impl PartialEq for GatewayEvent
Source§fn eq(&self, other: &GatewayEvent) -> bool
fn eq(&self, other: &GatewayEvent) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for GatewayEvent
Auto Trait Implementations§
impl Freeze for GatewayEvent
impl RefUnwindSafe for GatewayEvent
impl Send for GatewayEvent
impl Sync for GatewayEvent
impl Unpin for GatewayEvent
impl UnsafeUnpin for GatewayEvent
impl UnwindSafe for GatewayEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more