code_ranker_plugin_api/edge.rs
1//! A [`Edge`] — a directed edge between two nodes (an import, a call, a
2//! containment, …). The `kind` is the plugin's own vocabulary; its semantics
3//! (flow vs structural, label, hint) come from a matching
4//! [`EdgeKindSpec`](crate::EdgeKindSpec).
5
6use crate::attrs::Attributes;
7use crate::node::NodeId;
8use serde::{Deserialize, Serialize};
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Edge {
12 pub source: NodeId,
13 pub target: NodeId,
14 /// The plugin's vocabulary — "uses"/"contains"/"reexports"/… today;
15 /// "calls"/"reads"/"writes"/… later. Not interpreted by the core.
16 pub kind: String,
17 /// 1-based line in the *source* node's file where this edge is declared
18 /// (e.g. the `use`/`import` statement). `None` when the plugin can't place
19 /// it (synthetic/aggregated edges). Lets `check` point a cycle violation at
20 /// a concrete spot to break. Omitted from JSON when absent.
21 #[serde(default, skip_serializing_if = "Option::is_none")]
22 pub line: Option<u32>,
23 /// Free-form attributes (e.g. `external`, or language-specific keys),
24 /// described by the level's `edge_attributes` dictionary. Flattened into
25 /// the edge JSON object.
26 #[serde(flatten)]
27 pub attrs: Attributes,
28}