#[non_exhaustive]pub enum IngestSource {
RawText,
Url(String),
File {
filename: String,
content_type: Option<String>,
},
Api,
}Expand description
Source kinds accepted at ingest time.
IngestSource identifies where content originated, which affects validation
rules (e.g., whether a payload is required) and downstream processing.
§Source Types
RawText: Plain text supplied directly (requires text payload)Url(String): Content from a URL (requires text payload)File { filename, content_type }: Uploaded file (requires payload)Api: Generic API call (payload optional)
§Payload Requirements
| Source | Payload Required | Text Required |
|---|---|---|
RawText | Yes | Yes |
Url | Yes | Yes |
File | Yes | No |
Api | No | No |
§Examples
use ingest::IngestSource;
// Raw text input
let source = IngestSource::RawText;
// URL-sourced content
let source = IngestSource::Url("https://example.com/page".to_string());
// File upload
let source = IngestSource::File {
filename: "document.pdf".to_string(),
content_type: Some("application/pdf".to_string()),
};
// Generic API call
let source = IngestSource::Api;Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
RawText
Plain text supplied directly in the request body.
This source requires a text payload. The content will be whitespace-normalized during ingest.
§Example
use ingest::{IngestSource, IngestPayload, RawIngestRecord, IngestMetadata};
let record = RawIngestRecord {
id: "text-001".to_string(),
source: IngestSource::RawText,
metadata: IngestMetadata {
tenant_id: Some("tenant".to_string()),
doc_id: Some("doc".to_string()),
received_at: None,
original_source: None,
attributes: None,
},
payload: Some(IngestPayload::Text("Hello world".to_string())),
};Url(String)
Content logically associated with a URL.
This source requires a text payload and is typically used for content crawled from web pages.
§Example
use ingest::IngestSource;
let source = IngestSource::Url(
"https://example.com/article".to_string()
);File
An uploaded file with associated metadata.
This source requires a payload (text or binary) and captures file metadata for downstream processing.
§Fields
filename: The original filenamecontent_type: Optional MIME type (e.g., “application/pdf”)
§Example
use ingest::{IngestSource, IngestPayload, RawIngestRecord, IngestMetadata};
let record = RawIngestRecord {
id: "file-001".to_string(),
source: IngestSource::File {
filename: "report.pdf".to_string(),
content_type: Some("application/pdf".to_string()),
},
metadata: IngestMetadata {
tenant_id: Some("tenant".to_string()),
doc_id: Some("doc-123".to_string()),
received_at: None,
original_source: Some("uploads/report.pdf".to_string()),
attributes: None,
},
payload: Some(IngestPayload::Binary(vec![0x89, 0x50, 0x4E, 0x47])), // PNG header
};Fields
Api
Catch-all for ingests originating from an API call.
Unlike other sources, Api does not require a payload, making it suitable
for metadata-only events or API calls without content.
§Example
use ingest::{IngestSource, RawIngestRecord, IngestMetadata};
let record = RawIngestRecord {
id: "api-001".to_string(),
source: IngestSource::Api,
metadata: IngestMetadata {
tenant_id: Some("tenant".to_string()),
doc_id: Some("doc".to_string()),
received_at: None,
original_source: None,
attributes: Some(serde_json::json!({"event": "user_action"})),
},
payload: None, // Optional for Api source
};Trait Implementations§
Source§impl Clone for IngestSource
impl Clone for IngestSource
Source§fn clone(&self) -> IngestSource
fn clone(&self) -> IngestSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more