pub struct DocumentChunk {
pub document_id: String,
pub content: String,
pub chunk_index: usize,
pub start_position: usize,
pub end_position: usize,
pub overlap_previous: usize,
pub overlap_next: usize,
pub metadata: Metadata,
}Expand description
Document chunk for processing pipelines
Represents a portion of a document with positional information and overlap handling for better context preservation.
Fields§
§document_id: StringReference to parent document ID
content: StringChunk content
chunk_index: usizeChunk index within the document
start_position: usizeCharacter start position in original document
end_position: usizeCharacter end position in original document
overlap_previous: usizeOverlap with previous chunk (characters)
overlap_next: usizeOverlap with next chunk (characters)
metadata: MetadataChunk metadata (inherited from document + chunk-specific)
Implementations§
Source§impl DocumentChunk
impl DocumentChunk
Sourcepub fn new(
document_id: impl Into<String>,
content: impl Into<String>,
chunk_index: usize,
start_position: usize,
end_position: usize,
) -> Self
pub fn new( document_id: impl Into<String>, content: impl Into<String>, chunk_index: usize, start_position: usize, end_position: usize, ) -> Self
Create a new document chunk
Sourcepub fn with_overlap(self, previous: usize, next: usize) -> Self
pub fn with_overlap(self, previous: usize, next: usize) -> Self
Set overlap information
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Add metadata
Trait Implementations§
Source§impl Clone for DocumentChunk
impl Clone for DocumentChunk
Source§fn clone(&self) -> DocumentChunk
fn clone(&self) -> DocumentChunk
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 DocumentChunk
impl Debug for DocumentChunk
Source§impl<'de> Deserialize<'de> for DocumentChunk
impl<'de> Deserialize<'de> for DocumentChunk
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for DocumentChunk
impl RefUnwindSafe for DocumentChunk
impl Send for DocumentChunk
impl Sync for DocumentChunk
impl Unpin for DocumentChunk
impl UnwindSafe for DocumentChunk
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