pub struct Node {
pub id: String,
pub name: String,
pub node_type: NodeType,
pub kind: Option<String>,
pub subtype: Option<String>,
pub file: String,
pub line: usize,
pub end_line: usize,
pub text: Option<String>,
pub metadata: NodeMetadata,
pub hash: Option<String>,
}Expand description
A node in the code graph representing a code entity.
Fields§
§id: StringHierarchical node ID (e.g., “file.py:Module:Class:Method”)
name: StringEntity name
node_type: NodeTypeNode type: FILE, Container, Callable, or Data
kind: Option<String>Kind within the node type (e.g., “function”, “class”, “field”) None for FILE nodes
subtype: Option<String>Language-specific subtype (e.g., “struct”, “interface”, “class” for Container/type)
file: StringSource file path
line: usizeStarting line number (1-indexed)
end_line: usizeEnding line number (1-indexed)
text: Option<String>Source code text
metadata: NodeMetadataSemantic metadata
hash: Option<String>File content hash (only for FILE nodes)
Implementations§
Source§impl Node
impl Node
Sourcepub fn workspace(name: String) -> Self
pub fn workspace(name: String) -> Self
Create a new Workspace container node (root for multi-repo workspaces)
Sourcepub fn repository(name: String, metadata: NodeMetadata) -> Self
pub fn repository(name: String, metadata: NodeMetadata) -> Self
Create a new Repository container node (root of the graph hierarchy)
Sourcepub fn component(
id: String,
name: String,
manifest_path: String,
metadata: NodeMetadata,
) -> Self
pub fn component( id: String, name: String, manifest_path: String, metadata: NodeMetadata, ) -> Self
Create a new Component container node (npm package, Cargo crate, Go module, etc.)
§Arguments
id- Hierarchical node ID (e.g., “my-repo:packages/core”)name- Component name from manifest (e.g., “@myorg/core”)manifest_path- Path to the manifest file relative to repo rootmetadata- Component metadata (is_workspace_root, is_publishable)
Sourcepub fn source_file(
id: String,
file_path: String,
hash: String,
line_count: usize,
) -> Self
pub fn source_file( id: String, file_path: String, hash: String, line_count: usize, ) -> Self
Create a new source file Container node (replaces legacy FILE node type)
Sourcepub fn container(
id: String,
name: String,
kind: ContainerKind,
subtype: Option<String>,
file: String,
line: usize,
end_line: usize,
) -> Self
pub fn container( id: String, name: String, kind: ContainerKind, subtype: Option<String>, file: String, line: usize, end_line: usize, ) -> Self
Create a new Container node
Sourcepub fn callable(
id: String,
name: String,
kind: CallableKind,
file: String,
line: usize,
end_line: usize,
) -> Self
pub fn callable( id: String, name: String, kind: CallableKind, file: String, line: usize, end_line: usize, ) -> Self
Create a new Callable node
Sourcepub fn data(
id: String,
name: String,
kind: DataKind,
subtype: Option<String>,
file: String,
line: usize,
end_line: usize,
) -> Self
pub fn data( id: String, name: String, kind: DataKind, subtype: Option<String>, file: String, line: usize, end_line: usize, ) -> Self
Create a new Data node
Sourcepub fn with_metadata(self, metadata: NodeMetadata) -> Self
pub fn with_metadata(self, metadata: NodeMetadata) -> Self
Set the metadata
Sourcepub fn is_repository(&self) -> bool
pub fn is_repository(&self) -> bool
Check if this is a repository container node
Sourcepub fn is_workspace(&self) -> bool
pub fn is_workspace(&self) -> bool
Check if this is a workspace container node
Sourcepub fn is_component(&self) -> bool
pub fn is_component(&self) -> bool
Check if this is a component container node
Sourcepub fn is_container(&self) -> bool
pub fn is_container(&self) -> bool
Check if this is a Container node (any kind)
Sourcepub fn is_callable(&self) -> bool
pub fn is_callable(&self) -> bool
Check if this is a Callable node
Sourcepub fn container_kind(&self) -> Option<ContainerKind>
pub fn container_kind(&self) -> Option<ContainerKind>
Get the container kind if this is a Container node
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Node
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more