pub struct CodeChunker { /* private fields */ }Expand description
Code-aware chunker that splits at function/class boundaries.
Supports multiple programming languages and falls back to line-based chunking for unknown languages.
§Supported Languages
- Rust (.rs)
- Python (.py)
- JavaScript (.js, .jsx)
- TypeScript (.ts, .tsx)
- Go (.go)
- Java (.java)
- C/C++ (.c, .cpp, .h, .hpp)
- Ruby (.rb)
- PHP (.php)
§Examples
use rlm_rs::chunking::{Chunker, CodeChunker, ChunkerMetadata};
let chunker = CodeChunker::new();
let code = r#"
fn main() {
println!("Hello");
}
fn helper() {
println!("Helper");
}
"#;
let meta = ChunkerMetadata::new().content_type("rs");
let chunks = chunker.chunk(1, code, Some(&meta)).unwrap();
assert!(!chunks.is_empty());Implementations§
Source§impl CodeChunker
impl CodeChunker
Trait Implementations§
Source§impl Chunker for CodeChunker
impl Chunker for CodeChunker
Source§fn chunk(
&self,
buffer_id: i64,
text: &str,
metadata: Option<&ChunkMetadata>,
) -> Result<Vec<Chunk>>
fn chunk( &self, buffer_id: i64, text: &str, metadata: Option<&ChunkMetadata>, ) -> Result<Vec<Chunk>>
Chunks the input text into segments. Read more
Source§fn description(&self) -> &'static str
fn description(&self) -> &'static str
Returns a description of the chunking strategy.
Source§fn supports_parallel(&self) -> bool
fn supports_parallel(&self) -> bool
Returns whether this chunker supports parallel processing. Read more
Source§impl Clone for CodeChunker
impl Clone for CodeChunker
Source§fn clone(&self) -> CodeChunker
fn clone(&self) -> CodeChunker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CodeChunker
impl Debug for CodeChunker
Auto Trait Implementations§
impl Freeze for CodeChunker
impl RefUnwindSafe for CodeChunker
impl Send for CodeChunker
impl Sync for CodeChunker
impl Unpin for CodeChunker
impl UnwindSafe for CodeChunker
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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