vector_config/external/
encoding_rs.rs1use std::cell::RefCell;
2
3use encoding_rs::Encoding;
4use serde_json::Value;
5
6use crate::{
7 schema::{generate_string_schema, SchemaGenerator, SchemaObject},
8 Configurable, GenerateError, Metadata, ToValue,
9};
10
11impl Configurable for &'static Encoding {
12 fn referenceable_name() -> Option<&'static str> {
17 Some("encoding_rs::Encoding")
18 }
19
20 fn metadata() -> Metadata {
21 let mut metadata = Metadata::default();
22 metadata.set_description(
23 "An encoding as defined in the [Encoding Standard](https://encoding.spec.whatwg.org/).",
24 );
25 metadata
26 }
27
28 fn generate_schema(_: &RefCell<SchemaGenerator>) -> Result<SchemaObject, GenerateError> {
29 Ok(generate_string_schema())
30 }
31}
32
33impl ToValue for &'static Encoding {
34 fn to_value(&self) -> Value {
35 Value::String(self.name().into())
36 }
37}