vector_config/external/
no_proxy.rs

1use std::cell::RefCell;
2
3use serde_json::Value;
4
5use crate::{
6    schema::{generate_array_schema, SchemaGenerator, SchemaObject},
7    Configurable, GenerateError, Metadata, ToValue,
8};
9
10impl Configurable for no_proxy::NoProxy {
11    fn metadata() -> Metadata {
12        // Any schema that maps to a scalar type needs to be marked as transparent... and since we
13        // generate a schema equivalent to a string, we need to mark ourselves as transparent, too.
14        Metadata::with_transparent(true)
15    }
16
17    fn generate_schema(gen: &RefCell<SchemaGenerator>) -> Result<SchemaObject, GenerateError> {
18        // `NoProxy` (de)serializes itself as a vector of strings, without any constraints on the string value itself, so
19        // we just... do that.
20        generate_array_schema(&String::as_configurable_ref(), gen)
21    }
22}
23
24impl ToValue for no_proxy::NoProxy {
25    fn to_value(&self) -> Value {
26        serde_json::to_value(self).expect("Could not convert no-proxy list to JSON")
27    }
28}