springql_core/api/
spring_source_row.rs

1// This file is part of https://github.com/SpringQL/SpringQL which is licensed under MIT OR Apache-2.0. See file LICENSE-MIT or LICENSE-APACHE for full license details.
2
3mod spring_source_row_builder;
4
5pub use spring_source_row_builder::SpringSourceRowBuilder;
6
7use crate::{
8    api::error::Result,
9    stream_engine::autonomous_executor::{SchemalessRow, SourceRow},
10};
11
12/// Row object from an in memory sink queue.
13#[derive(Clone, Debug)]
14pub struct SpringSourceRow(SourceRow);
15
16impl SpringSourceRow {
17    pub(crate) fn new(source_row: SchemalessRow) -> Self {
18        let source_row = SourceRow::Raw(source_row);
19        Self(source_row)
20    }
21
22    /// Create a source row from a JSON string.
23    ///
24    /// # Failure
25    ///
26    /// - `SpringError::InvalidFormat` when:
27    ///   - `json` cannot be parsed as a JSON
28    pub fn from_json(json: &str) -> Result<Self> {
29        let source_row = SourceRow::from_json(json)?;
30        Ok(Self(source_row))
31    }
32
33    pub(crate) fn into_schemaless_row(self) -> Result<SchemalessRow> {
34        self.0.try_into()
35    }
36}