fiberplane_models/providers/schema/
config_schema.rs

1#[cfg(feature = "fp-bindgen")]
2use fp_bindgen::prelude::Serializable;
3use serde::{Deserialize, Serialize};
4
5use super::fields::*;
6
7/// Defines the fields that should be included in a provider's config.
8///
9/// Config data can be encoded as either JSON or YAML, so values must be
10/// representable in both.
11pub type ConfigSchema = Vec<ConfigField>;
12
13#[derive(Debug, Deserialize, Serialize)]
14#[cfg_attr(
15    feature = "fp-bindgen",
16    derive(Serializable),
17    fp(rust_module = "fiberplane_models::providers")
18)]
19#[non_exhaustive]
20#[serde(tag = "type", rename_all = "snake_case")]
21pub enum ConfigField {
22    Checkbox(CheckboxField),
23    Integer(IntegerField),
24    Select(SelectField),
25    Text(TextField),
26}
27
28impl From<CheckboxField> for ConfigField {
29    fn from(field: CheckboxField) -> Self {
30        Self::Checkbox(field)
31    }
32}
33
34impl From<IntegerField> for ConfigField {
35    fn from(field: IntegerField) -> Self {
36        Self::Integer(field)
37    }
38}
39
40impl From<SelectField> for ConfigField {
41    fn from(field: SelectField) -> Self {
42        Self::Select(field)
43    }
44}
45
46impl From<TextField> for ConfigField {
47    fn from(field: TextField) -> Self {
48        Self::Text(field)
49    }
50}