#[cfg(feature = "splitter-separator")]
pub use crate::by_separators::{KeepSeparator, SeparatorSplitConfig, SeparatorSplitter};
#[cfg(feature = "splitter-recursive")]
pub use crate::recursive::{
CustomLanguageConfig, RecursiveChunkConfig, RecursiveChunker, RecursiveSplitConfig,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct TextRange {
pub start: usize,
pub end: usize,
}
impl TextRange {
pub fn new(start: usize, end: usize) -> Self {
Self { start, end }
}
pub fn len(&self) -> usize {
self.end - self.start
}
pub fn is_empty(&self) -> bool {
self.start >= self.end
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct OutputPosition {
pub char_offset: usize,
pub line: u32,
pub column: u32,
}
#[derive(Debug, Clone)]
pub struct Chunk {
pub range: TextRange,
pub start: OutputPosition,
pub end: OutputPosition,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_text_range() {
let range = TextRange::new(0, 10);
assert_eq!(range.len(), 10);
assert!(!range.is_empty());
let empty = TextRange::new(5, 5);
assert_eq!(empty.len(), 0);
assert!(empty.is_empty());
}
}