#[non_exhaustive]pub struct Document {
pub id: DocumentId,
pub content: String,
pub metadata: Value,
pub source: Source,
pub lineage: Option<Lineage>,
pub namespace: Namespace,
}Expand description
The unit a RAG pipeline moves around — content plus everything downstream needs to know about where it came from.
Splitters consume one Document and emit several. Chunkers
consume a sequence and emit a transformed sequence (typically
the same length, with mutated content or metadata).
Loaders produce them; ingestion pipelines consume them.
metadata is operator-defined free-form JSON for filtering at
the vector-store layer — explicit fields above (source,
lineage, namespace) are the SDK-stamped boundary that every
pipeline must preserve.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: DocumentIdStable identifier for this document within its namespace.
content: StringThe textual content. Splitters slice this; chunkers may rewrite it (Contextual Retrieval prepends a generated context prefix).
metadata: ValueOperator-supplied free-form metadata. Vector stores typically expose this as a filterable JSON column.
source: SourceOrigin of this document or its top-level ancestor.
lineage: Option<Lineage>Split / chunk ancestry. None on the loader-produced root;
Some on every chunked descendant.
namespace: NamespaceMulti-tenant boundary (invariant 11). Every persistent
boundary the pipeline crosses respects this — silent
cross-tenant leakage is structurally impossible because
every loader, splitter, and pipeline takes a Namespace
at construction time.
Implementations§
Source§impl Document
impl Document
Sourcepub fn root(
id: impl Into<DocumentId>,
content: impl Into<String>,
source: Source,
namespace: Namespace,
) -> Self
pub fn root( id: impl Into<DocumentId>, content: impl Into<String>, source: Source, namespace: Namespace, ) -> Self
Construct a fresh root document — the shape a
crate::DocumentLoader emits before any splitter has
run. lineage is None; chunked descendants populate it.
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Builder-style metadata setter.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
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>,
impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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