Struct AssertionBuilder

Source
pub struct AssertionBuilder<S> { /* private fields */ }
Expand description

Configures and constructs an Assertion.

This builder uses a state pattern to ensure that the necessary fields are configured before a valid Assertion can be constructed. You may notice that some methods are only available once other methods have been called.

You must first define a span matcher, which defines how this assertion is matched to a given span, and then you must specify the assertion criteria itself, which defines the behavior of the span to assert for.

Once these are defined, an Assertion can be constructed by calling [finalize].

Implementations§

Source§

impl AssertionBuilder<NoMatcher>

Source

pub fn with_name<S>(self, name: S) -> AssertionBuilder<NoCriteria>
where S: Into<String>,

Sets the name of the span to match.

All span matchers, which includes [with_name], [with_target], [with_parent_name], and [with_span_field], are additive, which means a span must match all of them to match the assertion overall.

Source

pub fn with_target<S>(self, target: S) -> AssertionBuilder<NoCriteria>
where S: Into<String>,

Sets the target of the span to match.

All span matchers, which includes [with_name], [with_target], [with_parent_name], and [with_span_field], are additive, which means a span must match all of them to match the assertion overall.

Source§

impl AssertionBuilder<NoCriteria>

Source

pub fn with_name<S>(self, name: S) -> AssertionBuilder<NoCriteria>
where S: Into<String>,

Sets the name of the span to match.

All span matchers, which includes [with_name], [with_target], [with_parent_name], and [with_span_field], are additive, which means a span must match all of them to match the assertion overall.

Source

pub fn with_target<S>(self, target: S) -> AssertionBuilder<NoCriteria>
where S: Into<String>,

Sets the target of the span to match.

All span matchers, which includes [with_name], [with_target], [with_parent_name], and [with_span_field], are additive, which means a span must match all of them to match the assertion overall.

Source

pub fn with_parent_name<S>(self, name: S) -> AssertionBuilder<NoCriteria>
where S: Into<String>,

Sets the name of a parent span to match.

The span must have at least one parent span within its entire lineage that matches the given name.

All span matchers, which includes [with_name], [with_target], [with_parent_name], and [with_span_field], are additive, which means a span must match all of them to match the assertion overall.

Source

pub fn with_span_field<S>(self, field: S) -> AssertionBuilder<NoCriteria>
where S: Into<String>,

Adds a field which the span must contain to match.

The field is matched by name.

All span matchers, which includes [with_name], [with_target], and [with_span_field], are additive, which means a span must match all of them to match the assertion overall.

Source

pub fn was_created(self) -> AssertionBuilder<Constrained>

Asserts that a matching span was created at least once.

Source

pub fn was_entered(self) -> AssertionBuilder<Constrained>

Asserts that a matching span was entered at least once.

Source

pub fn was_exited(self) -> AssertionBuilder<Constrained>

Asserts that a matching span was exited at least once.

Source

pub fn was_closed(self) -> AssertionBuilder<Constrained>

Asserts that a matching span was closed at least once.

Source

pub fn was_not_created(self) -> AssertionBuilder<Constrained>

Asserts that a matching span was not created.

Source

pub fn was_not_entered(self) -> AssertionBuilder<Constrained>

Asserts that a matching span was not entered.

Source

pub fn was_not_exited(self) -> AssertionBuilder<Constrained>

Asserts that a matching span was not exited.

Source

pub fn was_not_closed(self) -> AssertionBuilder<Constrained>

Asserts that a matching span was not closed.

Source

pub fn was_created_exactly(self, n: usize) -> AssertionBuilder<Constrained>

Asserts that a matching span was created exactly n times.

Source

pub fn was_entered_exactly(self, n: usize) -> AssertionBuilder<Constrained>

Asserts that a matching span was entered exactly n times.

Source

pub fn was_exited_exactly(self, n: usize) -> AssertionBuilder<Constrained>

Asserts that a matching span was exited exactly n times.

Source

pub fn was_closed_exactly(self, n: usize) -> AssertionBuilder<Constrained>

Asserts that a matching span was closed exactly n times.

Source

pub fn was_created_at_least(self, n: usize) -> AssertionBuilder<Constrained>

Asserts that a matching span was created at least n times.

Source

pub fn was_entered_at_least(self, n: usize) -> AssertionBuilder<Constrained>

Asserts that a matching span was entered at least n times.

Source

pub fn was_exited_at_least(self, n: usize) -> AssertionBuilder<Constrained>

Asserts that a matching span was exited at least n times.

Source

pub fn was_closed_at_least(self, n: usize) -> AssertionBuilder<Constrained>

Asserts that a matching span was closed at least n times.

Source§

impl AssertionBuilder<Constrained>

Source

pub fn was_created(self) -> Self

Asserts that a matching span was created at least once.

Source

pub fn was_entered(self) -> Self

Asserts that a matching span was entered at least once.

Source

pub fn was_exited(self) -> Self

Asserts that a matching span was exited at least once.

Source

pub fn was_closed(self) -> Self

Asserts that a matching span was closed at least once.

Source

pub fn was_not_created(self) -> Self

Asserts that a matching span was not created.

Source

pub fn was_not_entered(self) -> Self

Asserts that a matching span was not entered.

Source

pub fn was_not_exited(self) -> Self

Asserts that a matching span was not exited.

Source

pub fn was_not_closed(self) -> Self

Asserts that a matching span was not closed.

Source

pub fn was_created_exactly(self, n: usize) -> Self

Asserts that a matching span was created exactly n times.

Source

pub fn was_entered_exactly(self, n: usize) -> Self

Asserts that a matching span was entered exactly n times.

Source

pub fn was_exited_exactly(self, n: usize) -> Self

Asserts that a matching span was exited exactly n times.

Source

pub fn was_closed_exactly(self, n: usize) -> Self

Asserts that a matching span was closed exactly n times.

Source

pub fn was_created_at_least(self, n: usize) -> Self

Asserts that a matching span was created at least n times.

Source

pub fn was_entered_at_least(self, n: usize) -> Self

Asserts that a matching span was entered at least n times.

Source

pub fn was_exited_at_least(self, n: usize) -> Self

Asserts that a matching span was exited at least n times.

Source

pub fn was_closed_at_least(self, n: usize) -> Self

Asserts that a matching span was closed at least n times.

Source

pub fn finalize(self) -> Assertion

Creates the finalized Assertion.

Once finalized, the assertion is live and its state will be updated going forward.

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
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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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