pub struct Chunk {Show 13 fields
pub content: String,
pub start_line: usize,
pub end_line: usize,
pub kind: ChunkKind,
pub context: Vec<String>,
pub path: String,
pub signature: Option<String>,
pub docstring: Option<String>,
pub is_complete: bool,
pub split_index: Option<usize>,
pub hash: String,
pub context_prev: Option<String>,
pub context_next: Option<String>,
}Expand description
Represents a chunk of code with metadata
Fields§
§content: StringThe actual content of the chunk
start_line: usizeStarting line number (0-indexed)
end_line: usizeEnding line number (0-indexed)
kind: ChunkKindType of chunk
context: Vec<String>Context breadcrumbs (e.g., [“File: main.rs”, “Class: Server”, “Function: handle_request”])
path: StringFile path this chunk belongs to
signature: Option<String>Function/method signature (if applicable)
Example: “fn sort<T: Ord>(items: Vec
docstring: Option<String>Extracted docstring/documentation comment
is_complete: boolWhether this chunk is complete (not split)
split_index: Option<usize>If this chunk was split, which part is it? (0, 1, 2…)
hash: StringContent hash for deduplication
context_prev: Option<String>Lines of code immediately before this chunk (for context)
context_next: Option<String>Lines of code immediately after this chunk (for context)
Implementations§
Source§impl Chunk
impl Chunk
Sourcepub fn new(
content: String,
start_line: usize,
end_line: usize,
kind: ChunkKind,
path: String,
) -> Self
pub fn new( content: String, start_line: usize, end_line: usize, kind: ChunkKind, path: String, ) -> Self
Create a new chunk with basic information
Sourcepub fn compute_hash(content: &str) -> String
pub fn compute_hash(content: &str) -> String
Compute SHA-256 hash of content for deduplication
Sourcepub fn estimate_memory_usage(&self) -> usize
pub fn estimate_memory_usage(&self) -> usize
TEST METHOD: Estimate memory usage of this chunk in bytes
Sourcepub fn contains_keyword(&self, keyword: &str) -> bool
pub fn contains_keyword(&self, keyword: &str) -> bool
TEST METHOD: Check if this chunk contains a specific keyword
Sourcepub fn is_duplicate_of(&self, other: &Chunk) -> bool
pub fn is_duplicate_of(&self, other: &Chunk) -> bool
Check if this chunk is likely a duplicate based on hash
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Get the number of lines in this chunk
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Get the size of this chunk in bytes
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Chunk
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin for Chunk
impl UnsafeUnpin for Chunk
impl UnwindSafe for Chunk
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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