pub struct Node {
pub id: NodeId,
pub vname: VName,
pub kind: String,
pub package: String,
pub line: Option<u32>,
}Expand description
A node in the code graph.
PartialEq compares all fields including package. Use node.id == other.id
for identity-only comparisons (two nodes are the same symbol regardless of
their package annotation).
Fields§
§id: NodeId§vname: VName§kind: String§package: StringSub-unit identity within the corpus (ADR-005 Rule 2).
Stored in nodes.package; not part of the BLAKE3 hash input.
Empty string for nodes where package identity is unknown or irrelevant.
| Language | Value |
|---|---|
| TypeScript | npm package name from package.json |
| Rust | Cargo package name from Cargo.toml |
| Python | top-level package dir (highest __init__.py) |
line: Option<u32>1-based source line of the symbol’s definition site.
None for file-kind nodes and synthetic import nodes.
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(vname: VName, kind: impl Into<String>) -> Node
pub fn new(vname: VName, kind: impl Into<String>) -> Node
Build a Node from a VName and a free-form kind string.
The id is derived deterministically from the VName. package
defaults to an empty string; use Node::with_package to set it.
line defaults to None; use Node::with_line to set it.
Sourcepub fn with_package(self, package: impl Into<String>) -> Node
pub fn with_package(self, package: impl Into<String>) -> Node
Set the package field and return self (builder pattern).
use travsr_core::{Node, VName};
let n = Node::new(VName::new("github.com/a/b", "", "src/lib.rs", "rust", "fn:main"), "function")
.with_package("my-crate");
assert_eq!(n.package, "my-crate");