pub struct Chunk {
pub id: ChunkId,
pub document_id: String,
pub content: String,
pub embedding: Option<Vec<f32>>,
pub position: usize,
pub metadata: Option<Value>,
pub created_at: Instant,
}Expand description
Document chunk
Fields§
§id: ChunkIdChunk ID
document_id: StringParent document ID
content: StringChunk content
embedding: Option<Vec<f32>>Chunk embedding (optional, for similarity)
position: usizeChunk position in document
metadata: Option<Value>Metadata
created_at: InstantCreation time
Implementations§
Source§impl Chunk
impl Chunk
Sourcepub fn new(
id: ChunkId,
document_id: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn new( id: ChunkId, document_id: impl Into<String>, content: impl Into<String>, ) -> Self
Create a new chunk
Sourcepub fn with_embedding(self, embedding: Vec<f32>) -> Self
pub fn with_embedding(self, embedding: Vec<f32>) -> Self
Add embedding
Sourcepub fn with_position(self, position: usize) -> Self
pub fn with_position(self, position: usize) -> Self
Set position
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Add metadata
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Chunk
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin for Chunk
impl UnsafeUnpin 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