chat has a vision (idk the state i jus want to commit)

This commit is contained in:
lda
2025-10-22 18:53:11 +07:00 Unverified
parent a534c58262
commit 0d9d800daf
4 changed files with 53 additions and 6 deletions
+2 -1
View File
@@ -12,8 +12,9 @@
//!
//! i also need to see devices and idk MAYBE maybe not MAYBE UHHHHHH maybe broadcast
//!
//! LOWK if this were to be calls to kernel or some bullshit then PLEASE because doing ts parsing its hell cuh
pub mod neighbor;
pub mod subcommands;
pub mod utils;
// i want a generalized way to build and call
+42
View File
@@ -0,0 +1,42 @@
//! ts
//!
//! deals with both ip a (addroutput) and ip l (commonoutput)
//!
//! lowk why its free but its indirection and its ass
use macaddr::{MacAddr, MacAddr6};
use serde::{Deserialize, Serialize};
/// i dont include what i dont know about (almost all ts)
#[derive(Debug, Serialize, Deserialize)]
struct CommmonOutput {
ifindex: u32,
ifname: String,
/// i imagine UP or DOWN, unknown
operstate: String,
// 6 has a serde and the enum doesnt? why.
address: Option<MacAddr6>,
}
#[derive(Serialize, Debug, Deserialize)]
struct AddrOutput {
#[serde(flatten)]
c: CommmonOutput,
addr_info: Vec<AddrInfo>,
}
// i be copying
// Raw JSON shape from ip -j -4 address show
#[derive(Debug, Deserialize, Serialize)]
struct AddrInfo {
family: Option<String>,
local: Option<String>,
prefixlen: Option<u8>,
broadcast: Option<String>,
scope: Option<String>,
label: Option<String>,
// many more exist; we only take what we need
}
+2
View File
@@ -0,0 +1,2 @@
pub mod neighbor;
pub mod address;
@@ -1,4 +1,4 @@
//! ```
//! ```bash
//! ip -j n s
//! ```
//!
@@ -14,14 +14,15 @@ use strum::{Display, EnumString};
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
pub struct NeighborInput {
/// supports only the last item (ignore), `to` keyword is optional
to: IpAddr,
/// supports only one item (it complains)
dev: String, // im all for simplicity
to: Option<IpAddr>,
/// supports only one item (it complains if multiple)
dev: Option<String>, // im all for simplicity
/// takes multiple, has to have `nud` before bro or it will think you `to`
nud: Vec<NUDState>,
}
// as input this must be lowercase. as output it is uppercase
/// docs for items come from a random ahh man website idk
#[derive(Debug, PartialEq, Eq, EnumString, Display, Clone, Copy, Hash, Serialize, Deserialize)]
#[strum(serialize_all = "lowercase", ascii_case_insensitive)]
#[serde(rename_all = "UPPERCASE")]
@@ -59,8 +60,9 @@ pub enum NUDState {
Failed,
}
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
/// everything i see
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
pub struct NeighborItem {
dst: IpAddr,
dev: String,