springql_core/stream_engine/autonomous_executor/row/foreign_row/
source_row.rs1mod can_frame_source_row;
4mod json_source_row;
5
6pub use can_frame_source_row::CANFrameSourceRow;
7pub use json_source_row::JsonSourceRow;
8
9use crate::{
10 api::{error::Result, SpringError},
11 stream_engine::autonomous_executor::row::schemaless_row::SchemalessRow,
12};
13
14#[derive(Clone, PartialEq, Debug)]
18pub enum SourceRow {
19 Json(JsonSourceRow),
20 CANFrame(CANFrameSourceRow),
21 Raw(SchemalessRow),
22}
23
24impl SourceRow {
25 pub fn from_json(json: &str) -> Result<Self> {
30 let json_source_row = JsonSourceRow::parse(json)?;
31 Ok(Self::Json(json_source_row))
32 }
33}
34
35impl TryFrom<SourceRow> for SchemalessRow {
36 type Error = SpringError;
37
38 fn try_from(row: SourceRow) -> Result<Self> {
39 match row {
40 SourceRow::Json(json_source_row) => json_source_row.into_schemaless_row(),
41 SourceRow::CANFrame(can_frame_source_row) => can_frame_source_row.into_schemaless_row(),
42 SourceRow::Raw(schemaless_row) => Ok(schemaless_row),
43 }
44 }
45}