ts fn can go. its getting less uses!

This commit is contained in:
lda
2026-04-28 18:15:41 +07:00 Verified
parent aa698a9f4b
commit d0fa6bf526
9 changed files with 40 additions and 28 deletions
+1 -4
View File
@@ -21,10 +21,7 @@ pub async fn resolve_devices(input: impl Into<String>) -> Result<Vec<Device>> {
/// directly from raw Linux source rows.
pub async fn inventory(query: InventoryQuery) -> Result<DeviceInventory> {
let neighbors = wakey_linux::devices::query_neighbors(&query).await?;
let leases = get_leases(wakey_core::LeaseQuery {
include_state: false,
})
.await?;
let leases = get_leases().await?;
let observations = match wakey_linux::dhcp::list_local_observations().await {
Ok(observations) => observations
.into_iter()
+14 -8
View File
@@ -1,16 +1,22 @@
use anyhow::{Context, Result};
use wakey_core::{DhcpLease, DhcpLeaseWithState, LeaseQuery};
use wakey_core::{DhcpLease, DhcpLeaseWithState};
/// Read DHCP leases and optionally enrich them with current neighbor-state data.
pub async fn get_leases(query: LeaseQuery) -> Result<Vec<DhcpLeaseWithState>> {
/// Read DHCP leases from dnsmasq plus remembered hook names.
pub async fn get_leases() -> Result<Vec<DhcpLeaseWithState>> {
let leases = wakey_linux::dhcp::read_dhcp_leases_with_names()
.await
.context("failed to read DHCP leases")?;
if query.include_state {
Ok(wakey_linux::dhcp::enrich_leases_with_nud_state(leases).await)
} else {
Ok(leases_without_state(leases))
}
Ok(leases_without_state(leases))
}
/// Read DHCP leases and enrich them with current neighbor state.
///
/// Prefer inventory for device status; this exists for the legacy leases view.
pub async fn get_leases_with_neighbor_state() -> Result<Vec<DhcpLeaseWithState>> {
let leases = wakey_linux::dhcp::read_dhcp_leases_with_names()
.await
.context("failed to read DHCP leases")?;
Ok(wakey_linux::dhcp::enrich_leases_with_nud_state(leases).await)
}
/// Wrap raw DHCP leases in the current service output shape without neighbor state.
+1 -1
View File
@@ -9,7 +9,7 @@ pub use inventory::{
inventory, local_observation_to_fact, merge_devices, merge_devices_with_observations,
resolve_devices,
};
pub use leases::{get_leases, leases_without_state};
pub use leases::{get_leases, get_leases_with_neighbor_state, leases_without_state};
pub use query::{resolve_query, resolve_selector};
pub use wake::{
broadcast_wake_targets, resolve_wake_targets, wake_explicit, wake_from_query, wake_targets,