Skip to main content

semtree_core/
chunk.rs

1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4use crate::{Language, Span};
5
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7#[serde(rename_all = "snake_case")]
8pub enum ChunkKind {
9    Function,
10    Method,
11    Struct,
12    Enum,
13    Trait,
14    Impl,
15    Module,
16    Class,
17    File,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct Chunk {
22    /// Unique identifier (hash of path + span)
23    pub id: String,
24    /// Source file
25    pub path: PathBuf,
26    /// Programming language
27    pub language: Language,
28    /// Kind of code construct
29    pub kind: ChunkKind,
30    /// Name of the construct (e.g. function name)
31    pub name: Option<String>,
32    /// Raw source text
33    pub content: String,
34    /// Location in source file
35    pub span: Span,
36    /// Docstring / leading comment if any
37    pub doc: Option<String>,
38}