Trait vector_config::Configurable

source ·
pub trait Configurable {
    // Required method
    fn generate_schema(
        gen: &RefCell<SchemaGenerator>,
    ) -> Result<SchemaObject, GenerateError>
       where Self: Sized;

    // Provided methods
    fn referenceable_name() -> Option<&'static str>
       where Self: Sized { ... }
    fn is_optional() -> bool
       where Self: Sized { ... }
    fn metadata() -> Metadata
       where Self: Sized { ... }
    fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>
       where Self: Sized { ... }
    fn as_configurable_ref() -> ConfigurableRef
       where Self: Sized + 'static { ... }
}
Expand description

A type that can be represented in a Vector configuration.

In Vector, we want to be able to generate a schema for our configuration such that we can have a Rust-agnostic definition of exactly what is configurable, what values are allowed, what bounds exist, and so on and so forth.

Configurable provides the machinery to allow describing and encoding the shape of a type, recursively, so that by instrumenting all transitive types of the configuration, the schema can be discovered by generating the schema from some root type.

Required Methods§

source

fn generate_schema( gen: &RefCell<SchemaGenerator>, ) -> Result<SchemaObject, GenerateError>
where Self: Sized,

Generates the schema for this value.

§Errors

If an error occurs while generating the schema, an error variant will be returned describing the issue.

Provided Methods§

source

fn referenceable_name() -> Option<&'static str>
where Self: Sized,

Gets the referenceable name of this value, if any.

When specified, this implies the value is both complex and standardized, and should be reused within any generated schema it is present in.

source

fn is_optional() -> bool
where Self: Sized,

Whether or not this value is optional.

This is specifically used to determine when a field is inherently optional, such as a field that is a true map like HashMap<K, V>. This doesn’t apply to objects (i.e. structs) because structs are implicitly non-optional: they have a fixed shape and size, and so on.

Maps, by definition, are inherently free-form, and thus inherently optional. Thus, this method should likely not be overridden except for implementing Configurable for map types. If you’re using it for something else, you are expected to know what you’re doing.

source

fn metadata() -> Metadata
where Self: Sized,

Gets the metadata for this value.

source

fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>
where Self: Sized,

Validates the given metadata against this type.

This allows for validating specific aspects of the given metadata, such as validation bounds, and so on, to ensure they are valid for the given type. In some cases, such as with numeric types, there is a limited amount of validation that can occur within the Configurable derive macro, and additional validation must happen at runtime when the Configurable trait is being used, which this method allows for.

source

fn as_configurable_ref() -> ConfigurableRef
where Self: Sized + 'static,

Create a new configurable reference table.

Implementations on Foreign Types§

source§

impl Configurable for &'static Encoding

source§

impl Configurable for SocketAddr

source§

impl Configurable for Option<DurationMilliSeconds<u64, Strict>>

source§

impl Configurable for bool

source§

impl Configurable for char

source§

impl Configurable for f32

source§

impl Configurable for f64

source§

impl Configurable for i8

source§

impl Configurable for i16

source§

impl Configurable for i32

source§

impl Configurable for i64

source§

impl Configurable for isize

source§

impl Configurable for u8

source§

impl Configurable for u16

source§

impl Configurable for u32

source§

impl Configurable for u64

source§

impl Configurable for ()

source§

impl Configurable for usize

source§

impl Configurable for String

source§

impl Configurable for Duration

source§

impl Configurable for PathBuf

source§

impl Configurable for StatusCode

source§

impl Configurable for DurationMilliSeconds<u64, Strict>

source§

impl Configurable for DurationSeconds<u64, Strict>

source§

impl Configurable for DurationSecondsWithFrac<f64, Strict>

source§

impl Configurable for Url

source§

impl Configurable for NonZeroI8

source§

impl Configurable for NonZeroI16

source§

impl Configurable for NonZeroI32

source§

impl Configurable for NonZeroI64

source§

impl Configurable for NonZeroU8

source§

impl Configurable for NonZeroU16

source§

impl Configurable for NonZeroU32

source§

impl Configurable for NonZeroU64

source§

impl Configurable for NonZeroUsize

source§

impl Configurable for KeyString

source§

impl Configurable for NoProxy

source§

impl Configurable for QueryNode

source§

impl Configurable for TimeZone

source§

impl Configurable for Tz

source§

impl Configurable for Value

source§

impl Configurable for VrlRuntime

source§

impl<K, V> Configurable for BTreeMap<K, V>
where K: ConfigurableString + Ord + ToValue + 'static, V: Configurable + ToValue + 'static,

source§

impl<K, V> Configurable for HashMap<K, V>
where K: ConfigurableString + ToValue + Hash + Eq + 'static, V: Configurable + ToValue + 'static,

source§

impl<T> Configurable for Option<T>
where T: Configurable + ToValue + 'static,

source§

impl<T> Configurable for Vec<T>
where T: Configurable + ToValue + 'static,

source§

impl<T> Configurable for As<T>
where T: Configurable,

source§

impl<TZ> Configurable for DateTime<TZ>
where TZ: TimeZone,

source§

impl<V> Configurable for BTreeSet<V>
where V: Configurable + ToValue + Eq + Hash + 'static,

source§

impl<V> Configurable for HashSet<V>
where V: Configurable + ToValue + Eq + Hash + 'static,

Implementors§

source§

impl<I, H> Configurable for Delegated<I, H>
where H: Configurable,

source§

impl<K, V> Configurable for IndexMap<K, V>
where K: ConfigurableString + ToValue + Hash + Eq + 'static, V: Configurable + ToValue + 'static,

source§

impl<V> Configurable for IndexSet<V>
where V: Configurable + ToValue + Hash + Eq + 'static,