Skip to main content

IngestMetadata

Struct IngestMetadata 

Source
pub struct IngestMetadata {
    pub tenant_id: Option<String>,
    pub doc_id: Option<String>,
    pub received_at: Option<DateTime<Utc>>,
    pub original_source: Option<String>,
    pub attributes: Option<Value>,
}
Expand description

Metadata associated with an ingest request.

IngestMetadata carries contextual information about the content being ingested. All fields are optional and will be defaulted during normalization if not provided.

§Field Defaults

FieldDefault Behavior
tenant_idFalls back to IngestConfig::default_tenant_id
doc_idDerived via UUIDv5 if not provided
received_atSet to current UTC time
original_sourceRemains None if not provided
attributesRemains None if not provided

§Examples

§Minimal Metadata

use ingest::IngestMetadata;

let metadata = IngestMetadata {
    tenant_id: None,
    doc_id: None,
    received_at: None,
    original_source: None,
    attributes: None,
};
// All fields will be defaulted during ingest

§Full Metadata

use ingest::IngestMetadata;
use chrono::Utc;
use serde_json::json;

let metadata = IngestMetadata {
    tenant_id: Some("acme-corp".to_string()),
    doc_id: Some("report-q4-2024".to_string()),
    received_at: Some(Utc::now()),
    original_source: Some("https://docs.example.com/reports/q4".to_string()),
    attributes: Some(json!({
        "department": "Engineering",
        "classification": "internal",
        "tags": ["quarterly", "2024"]
    })),
};

Fields§

§tenant_id: Option<String>

Optional tenant identifier for multi-tenant isolation.

When None or empty after sanitization, falls back to IngestConfig::default_tenant_id.

§Example

use ingest::IngestMetadata;

let metadata = IngestMetadata {
    tenant_id: Some("tenant-123".to_string()),
    doc_id: None,
    received_at: None,
    original_source: None,
    attributes: None,
};
§doc_id: Option<String>

Optional document identifier.

When None or empty after sanitization, a deterministic UUIDv5 is generated using IngestConfig::doc_id_namespace: UUIDv5(namespace, tenant_id + "\0" + record_id)

§Example

use ingest::IngestMetadata;

let metadata = IngestMetadata {
    tenant_id: None,
    doc_id: Some("doc-abc-123".to_string()),
    received_at: None,
    original_source: None,
    attributes: None,
};
§received_at: Option<DateTime<Utc>>

Optional timestamp when the content was received.

When None, defaults to the current UTC time at ingest. Can be validated against future time if MetadataPolicy::reject_future_timestamps is enabled.

§Example

use ingest::IngestMetadata;
use chrono::Utc;

let metadata = IngestMetadata {
    tenant_id: None,
    doc_id: None,
    received_at: Some(Utc::now()),
    original_source: None,
    attributes: None,
};
§original_source: Option<String>

Optional original source identifier (e.g., URL or external ID).

This is a human-readable reference to where the content originated. Control characters are stripped during sanitization.

§Example

use ingest::IngestMetadata;

let metadata = IngestMetadata {
    tenant_id: None,
    doc_id: None,
    received_at: None,
    original_source: Some("https://example.com/source".to_string()),
    attributes: None,
};
§attributes: Option<Value>

Arbitrary JSON attributes for extensibility.

This field can store any JSON-serializable data for application-specific use cases. Size is limited by MetadataPolicy::max_attribute_bytes when configured.

§Example

use ingest::IngestMetadata;
use serde_json::json;

let metadata = IngestMetadata {
    tenant_id: None,
    doc_id: None,
    received_at: None,
    original_source: None,
    attributes: Some(json!({
        "category": "report",
        "priority": "high",
        "metadata": {
            "author": "Jane Smith",
            "department": "Engineering"
        }
    })),
};

Trait Implementations§

Source§

impl Clone for IngestMetadata

Source§

fn clone(&self) -> IngestMetadata

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IngestMetadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for IngestMetadata

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for IngestMetadata

Source§

fn eq(&self, other: &IngestMetadata) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for IngestMetadata

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for IngestMetadata

Source§

impl StructuralPartialEq for IngestMetadata

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,