Skip to main content

vector_core/
lib.rs

1//! The Vector Core Library
2//!
3//! The Vector Core Library are the foundational pieces needed to make a vector
4//! and is not vector with pieces missing. While this library is obviously
5//! tailored to the needs of vector it is written in such a way to make
6//! experimentation and testing _in the library_ cheap and demonstrative.
7//!
8//! This library was extracted from the top-level project package, discussed in
9//! RFC 7027.
10
11#![deny(warnings)]
12#![deny(clippy::all)]
13#![deny(clippy::pedantic)]
14#![deny(unreachable_pub)]
15#![deny(unused_allocation)]
16#![deny(unused_extern_crates)]
17#![deny(unused_assignments)]
18#![deny(unused_comparisons)]
19#![allow(clippy::default_trait_access)] // triggers on generated prost code
20#![allow(clippy::float_cmp)]
21#![allow(clippy::match_wildcard_for_single_variants)]
22#![allow(clippy::module_name_repetitions)]
23#![allow(clippy::must_use_candidate)] // many false positives in this package
24#![allow(clippy::non_ascii_literal)] // using unicode literals is a-okay in vector
25#![allow(clippy::unnested_or_patterns)] // nightly-only feature as of 1.51.0
26#![allow(clippy::type_complexity)] // long-types happen, especially in async code
27
28pub mod config;
29pub mod event;
30pub mod fanout;
31pub mod ipallowlist;
32pub mod latency;
33pub mod metrics;
34pub mod partition;
35pub mod schema;
36pub mod serde;
37pub mod sink;
38pub mod source;
39pub mod source_sender;
40pub mod span_fields;
41pub mod tcp;
42#[cfg(test)]
43mod test_util;
44pub mod time;
45pub mod tls;
46pub mod transform;
47pub mod vrl;
48
49use std::path::PathBuf;
50
51pub use event::EstimatedJsonEncodedSizeOf;
52use float_eq::FloatEq;
53
54pub use crate::vrl::compile_vrl;
55
56#[macro_use]
57extern crate tracing;
58
59pub fn default_data_dir() -> Option<PathBuf> {
60    Some(PathBuf::from("/var/lib/vector/"))
61}
62
63pub(crate) use vector_common::{Error, Result};
64
65pub(crate) fn float_eq(l_value: f64, r_value: f64) -> bool {
66    (l_value.is_nan() && r_value.is_nan()) || l_value.eq_ulps(&r_value, &1)
67}
68
69// These macros aren't actually usable in lib crates without some `vector_lib` shenanigans.
70#[macro_export]
71macro_rules! emit {
72    ($event:expr) => {
73        vector_lib::internal_event::emit($event)
74    };
75}
76
77#[macro_export]
78macro_rules! register {
79    ($event:expr) => {
80        vector_lib::internal_event::register($event)
81    };
82}
83
84pub use span_fields::SpanField;
85
86// Re-export `inventory` so `register_extra_span_field!` can resolve `submit!` through this
87// crate without forcing downstream callers to declare `inventory` as a direct dependency.
88#[doc(hidden)]
89pub use inventory as __inventory;