// We allow dead code because some of the things we're testing are meant to ensure that the macros do the right thing // for codegen i.e. not doing codegen for fields that `serde` is going to skip, etc. #![allow(dead_code)] #![allow(clippy::print_stdout)] // tests #![allow(clippy::print_stderr)] // tests use std::{ collections::HashMap, fmt, net::{Ipv4Addr, SocketAddr, SocketAddrV4}, num::NonZeroU64, path::PathBuf, time::Duration, }; use indexmap::IndexMap; use serde_with::serde_as; use vector_config::{ ConfigurableString, component::GenerateConfig, configurable_component, schema::generate_root_schema, }; /// A templated string. #[configurable_component] #[configurable(metadata(docs::templateable))] #[derive(Clone, Debug, Default, Eq, Hash, PartialEq)] #[serde(try_from = "String", into = "String")] pub struct Template { /// The template string. src: String, #[serde(skip)] has_ts: bool, #[serde(skip)] has_fields: bool, } impl ConfigurableString for Template {} impl fmt::Display for Template { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.src) } } impl TryFrom for Template { type Error = String; fn try_from(src: String) -> Result { if src.is_empty() { Err("wahhh".to_string()) } else { Ok(Self { src, has_ts: false, has_fields: false, }) } } } impl From