pub struct JsonSource { /* private fields */ }Expand description
A JSON/NDJSON file data source with schema inference and compression support.
§Examples
ⓘ
use term_guard::sources::{JsonSource, JsonOptions, JsonFormatType};
// NDJSON file (auto-detected)
let source = JsonSource::new("data/events.ndjson")?;
// Regular JSON with custom options
let options = JsonOptions {
format: JsonFormatType::Json,
..Default::default()
};
let source = JsonSource::with_options("data/config.json", options)?;
// Compressed NDJSON files with glob
let source = JsonSource::from_glob("logs/*.jsonl.gz").await?;Implementations§
Source§impl JsonSource
impl JsonSource
Sourcepub fn new(path: impl Into<String>) -> Result<Self>
pub fn new(path: impl Into<String>) -> Result<Self>
Creates a new JSON source from a single file path.
Sourcepub fn with_options(
path: impl Into<String>,
options: JsonOptions,
) -> Result<Self>
pub fn with_options( path: impl Into<String>, options: JsonOptions, ) -> Result<Self>
Creates a new JSON source with custom options.
Sourcepub fn from_paths(paths: Vec<String>) -> Result<Self>
pub fn from_paths(paths: Vec<String>) -> Result<Self>
Creates a JSON source from multiple file paths.
Sourcepub async fn from_glob(pattern: impl Into<String>) -> Result<Self>
pub async fn from_glob(pattern: impl Into<String>) -> Result<Self>
Creates a JSON source from a glob pattern.
Sourcepub async fn from_globs(patterns: Vec<String>) -> Result<Self>
pub async fn from_globs(patterns: Vec<String>) -> Result<Self>
Creates a JSON source from multiple glob patterns.
Sourcepub fn with_custom_options(self, options: JsonOptions) -> Self
pub fn with_custom_options(self, options: JsonOptions) -> Self
Sets custom options for this JSON source.
Trait Implementations§
Source§impl Clone for JsonSource
impl Clone for JsonSource
Source§fn clone(&self) -> JsonSource
fn clone(&self) -> JsonSource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl DataSource for JsonSource
impl DataSource for JsonSource
Source§fn register_with_telemetry<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 SessionContext,
table_name: &'life2 str,
telemetry: Option<&'life3 Arc<TermTelemetry>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn register_with_telemetry<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 SessionContext,
table_name: &'life2 str,
telemetry: Option<&'life3 Arc<TermTelemetry>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Registers this data source with telemetry support. Read more
Source§fn schema(&self) -> Option<&Arc<Schema>>
fn schema(&self) -> Option<&Arc<Schema>>
Returns the schema of this data source if known. Read more
Source§fn description(&self) -> String
fn description(&self) -> String
Returns a human-readable description of this data source.
Source§fn register<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 SessionContext,
table_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn register<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 SessionContext,
table_name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Registers this data source with the given session context. Read more
Auto Trait Implementations§
impl Freeze for JsonSource
impl RefUnwindSafe for JsonSource
impl Send for JsonSource
impl Sync for JsonSource
impl Unpin for JsonSource
impl UnwindSafe for JsonSource
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