Struct vector_core::schema::Definition

source ·
pub struct Definition { /* private fields */ }
Expand description

The definition of a schema.

This struct contains all the information needed to inspect the schema of an event emitted by a source/transform.

Implementations§

source§

impl Definition

source

pub fn any() -> Self

The most general possible definition. The Kind is any, and all log_namespaces are enabled.

source

pub fn new_with_default_metadata( event_kind: Kind, log_namespaces: impl Into<BTreeSet<LogNamespace>>, ) -> Self

Creates a new definition that is of the event kind specified, and an empty object for metadata. There are no meanings. The log_namespaces are used to list the possible namespaces the schema is for.

source

pub fn new( event_kind: Kind, metadata_kind: Kind, log_namespaces: impl Into<BTreeSet<LogNamespace>>, ) -> Self

Creates a new definition, specifying both the event and metadata kind. There are no meanings. The log_namespaces are used to list the possible namespaces the schema is for.

source

pub fn default_legacy_namespace() -> Self

An object with any fields, and the Legacy namespace. This is the default schema for a source that does not explicitly provide one yet.

source

pub fn empty_legacy_namespace() -> Self

An object with no fields, and the Legacy namespace. This is what most sources use for the legacy namespace.

source

pub fn default_for_namespace(log_namespaces: &BTreeSet<LogNamespace>) -> Self

Returns the source schema for a source that produce the listed log namespaces, but an explicit schema was not provided.

source

pub fn log_namespaces(&self) -> &BTreeSet<LogNamespace>

The set of possible log namespaces that events can use. When merged, this is the union of all inputs.

source

pub fn with_standard_vector_source_metadata(self) -> Self

Adds the source_type and ingest_timestamp metadata fields, which are added to every Vector source. This function should be called in the same order as the values are actually inserted into the event.

source

pub fn with_source_metadata( self, source_name: &str, legacy_path: Option<LegacyKey<OwnedValuePath>>, vector_path: &OwnedValuePath, kind: Kind, meaning: Option<&str>, ) -> Self

This should be used wherever LogNamespace::insert_source_metadata is used to insert metadata. This automatically detects which log namespaces are used, and also automatically determines if there are possible conflicts from existing field names (usually from the selected decoder). This function should be called in the same order as the values are actually inserted into the event.

source

pub fn with_vector_metadata( self, legacy_path: Option<&OwnedValuePath>, vector_path: &OwnedValuePath, kind: Kind, meaning: Option<&str>, ) -> Self

This should be used wherever LogNamespace::insert_vector_metadata is used to insert metadata. This automatically detects which log namespaces are used, and also automatically determines if there are possible conflicts from existing field names (usually from the selected decoder). This function should be called in the same order as the values are actually inserted into the event.

source

pub fn with_field( self, target_path: &OwnedTargetPath, kind: Kind, meaning: Option<&str>, ) -> Self

Add type information for an event or metadata field. A non-root required field means the root type must be an object, so the type will be automatically restricted to an object.

§Panics
  • If the path is not root, and the definition does not allow the type to be an object.
source

pub fn with_event_field( self, path: &OwnedValuePath, kind: Kind, meaning: Option<&str>, ) -> Self

Add type information for an event field. A non-root required field means the root type must be an object, so the type will be automatically restricted to an object.

§Panics
  • If the path is not root, and the definition does not allow the type to be an object.
  • Provided path has one or more coalesced segments (e.g. .(foo | bar)).
source

pub fn try_with_field( self, path: &OwnedValuePath, kind: Kind, meaning: Option<&str>, ) -> Self

Add type information for an event field. This inserts type information similar to LogEvent::try_insert.

source

pub fn with_metadata_field( self, path: &OwnedValuePath, kind: Kind, meaning: Option<&str>, ) -> Self

Add type information for an event field. A non-root required field means the root type must be an object, so the type will be automatically restricted to an object.

§Panics
  • If the path is not root, and the definition does not allow the type to be an object
  • Provided path has one or more coalesced segments (e.g. .(foo | bar)).
source

pub fn optional_field( self, path: &OwnedValuePath, kind: Kind, meaning: Option<&str>, ) -> Self

Add type information for an optional event field.

§Panics

See Definition::require_field.

source

pub fn with_meaning(self, target_path: OwnedTargetPath, meaning: &str) -> Self

Register a semantic meaning for the definition.

§Panics

This method panics if the provided path points to an unknown location in the collection.

source

pub fn add_meaning(&mut self, target_path: OwnedTargetPath, meaning: &str)

Adds the meaning pointing to the given path to our list of meanings.

§Panics

This method panics if the provided path points to an unknown location in the collection.

source

pub fn try_with_meaning( &mut self, target_path: OwnedTargetPath, meaning: &str, ) -> Result<(), &'static str>

Register a semantic meaning for the definition.

§Errors

Returns an error if the provided path points to an unknown location in the collection.

source

pub fn unknown_fields(self, unknown: impl Into<Kind>) -> Self

Set the kind for all unknown fields.

source

pub fn merge(self, other: Self) -> Self

Merge other definition into self.

This just takes the union of both definitions.

source

pub fn combine_log_namespaces( log_namespaces: &BTreeSet<LogNamespace>, legacy: Self, vector: Self, ) -> Self

If the schema definition depends on the LogNamespace, this combines the individual definitions for each LogNamespace.

source

pub fn meaning_path(&self, meaning: &str) -> Option<&OwnedTargetPath>

Returns an OwnedTargetPath into an event, based on the provided meaning, if the meaning exists.

source

pub fn invalid_meaning( &self, meaning: &str, ) -> Option<&BTreeSet<OwnedTargetPath>>

source

pub fn meanings(&self) -> impl Iterator<Item = (&String, &OwnedTargetPath)>

source

pub fn add_meanings<'a>( &'a mut self, meanings: impl Iterator<Item = (&'a String, &'a OwnedTargetPath)>, )

Adds the meanings provided by an iterator over the given meanings.

§Panics

This method panics if the provided path from any of the incoming meanings point to an unknown location in the collection.

source

pub fn event_kind(&self) -> &Kind

source

pub fn event_kind_mut(&mut self) -> &mut Kind

source

pub fn metadata_kind(&self) -> &Kind

source

pub fn kind_at<'a>(&self, target_path: impl TargetPath<'a>) -> Kind

Trait Implementations§

source§

impl Clone for Definition

source§

fn clone(&self) -> Definition

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Definition

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Definition

source§

fn eq(&self, other: &Definition) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Definition

source§

fn partial_cmp(&self, other: &Definition) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl StructuralPartialEq for Definition

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

§

type Error = <Target as OctetsFrom<Source>>::Error

§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>

Change the foreground color to black
§

fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>

Change the background color to black
§

fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>

Change the foreground color to red
§

fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>

Change the background color to red
§

fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>

Change the foreground color to green
§

fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>

Change the background color to green
§

fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>

Change the background color to yellow
§

fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>

Change the foreground color to blue
§

fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>

Change the background color to blue
§

fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to magenta
§

fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to purple
§

fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to purple
§

fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>

Change the background color to cyan
§

fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>

Change the foreground color to white
§

fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>

Change the background color to white
§

fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>

Change the background color to the terminal default
§

fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>

Change the background color to bright red
§

fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>

Change the background color to bright white
§

fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>

Make the text bold
§

fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>

Make the text dim
§

fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>

Make the text italicized
§

fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>

Make the text italicized
Make the text blink
Make the text blink (but fast!)
§

fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>

Swap the foreground and background colors
§

fn hidden<'a>(&'a self) -> HiddenDisplay<'a, Self>

Hide the text
§

fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more