fuel_streams_subject/
lib.rs

1#![doc = include_str!("../README.md")]
2mod payload;
3mod schema;
4
5pub mod subject {
6    pub use std::fmt::Debug;
7
8    use downcast_rs::{impl_downcast, Downcast};
9    pub use indexmap::IndexMap;
10    pub use serde_json;
11    pub use subject_derive::*;
12
13    #[allow(unused_imports)]
14    pub use crate::{payload::*, schema::*};
15
16    pub trait IntoSubject: Debug + Downcast + Send + Sync + 'static {
17        fn id(&self) -> &'static str;
18        fn parse(&self) -> String;
19        fn query_all(&self) -> &'static str;
20        fn to_sql_where(&self) -> Option<String>;
21        fn to_sql_select(&self) -> Option<String>;
22        fn schema(&self) -> Schema;
23        fn to_payload(&self) -> SubjectPayload;
24    }
25    impl_downcast!(IntoSubject);
26
27    pub trait SubjectBuildable: Debug {
28        fn new() -> Self;
29    }
30
31    pub fn parse_param<V: ToString>(param: &Option<V>) -> String {
32        match param {
33            Some(val) => val.to_string(),
34            None => "*".to_string(),
35        }
36    }
37}