pub struct Chunk {
pub id: Uuid,
pub text: String,
pub index: usize,
pub start_char: usize,
pub end_char: usize,
pub token_count: Option<usize>,
pub section: Option<String>,
pub page: Option<usize>,
pub embedding_ids: EmbeddingIds,
}Expand description
A chunk of text from a document.
Documents are split into chunks for embedding and retrieval. Each chunk maintains positional information and embedding references.
§Example
use reasonkit::{Chunk, EmbeddingIds};
use uuid::Uuid;
let chunk = Chunk {
id: Uuid::new_v4(),
text: "This is a chunk of text...".to_string(),
index: 0,
start_char: 0,
end_char: 26,
token_count: Some(7),
section: Some("Introduction".to_string()),
page: Some(1),
embedding_ids: EmbeddingIds::default(),
};Fields§
§id: UuidUnique identifier for this chunk
text: StringThe text content of the chunk
index: usizePosition index within the document
start_char: usizeStarting character position in the original document
end_char: usizeEnding character position in the original document
token_count: Option<usize>Estimated token count for the chunk
section: Option<String>Section or heading this chunk belongs to
page: Option<usize>Page number (for paginated documents)
embedding_ids: EmbeddingIdsReferences to stored embeddings
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Chunk
impl<'de> Deserialize<'de> for Chunk
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 Chunk
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin 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
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> 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>
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