pub struct FixedChunker { /* private fields */ }Expand description
Fixed-size chunker that splits text at character boundaries.
This is the simplest chunking strategy, splitting text into fixed-size segments with optional overlap. It ensures chunks never split multi-byte UTF-8 characters.
§Examples
use rlm_rs::chunking::{Chunker, FixedChunker};
let chunker = FixedChunker::with_size(100);
let text = "Hello, world! ".repeat(20);
let chunks = chunker.chunk(1, &text, None).unwrap();
for chunk in &chunks {
assert!(chunk.size() <= 100);
}Implementations§
Source§impl FixedChunker
impl FixedChunker
Sourcepub const fn with_size(chunk_size: usize) -> Self
pub const fn with_size(chunk_size: usize) -> Self
Creates a fixed chunker with custom chunk size and no overlap.
§Arguments
chunk_size- Target size for each chunk in characters.
Sourcepub const fn with_size_and_overlap(chunk_size: usize, overlap: usize) -> Self
pub const fn with_size_and_overlap(chunk_size: usize, overlap: usize) -> Self
Creates a fixed chunker with custom size and overlap.
§Arguments
chunk_size- Target size for each chunk in characters.overlap- Number of characters to overlap between chunks.
Sourcepub const fn line_aware(self, enabled: bool) -> Self
pub const fn line_aware(self, enabled: bool) -> Self
Sets whether to align chunks to line boundaries.
When enabled, chunks will end at the nearest newline before the target size (if one exists within a reasonable range).
Trait Implementations§
Source§impl Chunker for FixedChunker
impl Chunker for FixedChunker
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 FixedChunker
impl Clone for FixedChunker
Source§fn clone(&self) -> FixedChunker
fn clone(&self) -> FixedChunker
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 FixedChunker
impl Debug for FixedChunker
Auto Trait Implementations§
impl Freeze for FixedChunker
impl RefUnwindSafe for FixedChunker
impl Send for FixedChunker
impl Sync for FixedChunker
impl Unpin for FixedChunker
impl UnwindSafe for FixedChunker
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