Skip to main content

Traced

Struct Traced 

Source
pub struct Traced<T>
where T: Try,
{ /* private fields */ }
Expand description

The wrapper around a Try-type with associated tracing event. You will usually not interact directly with this type but rather with the trait Trace.

Implementations§

Source§

impl<T, E> Traced<Result<T, E>>

Source

pub fn err(self) -> Option<E>

Converts from TracedResult<T, E> to Option<E>, emitting any tracing entry in the process.

Source

pub fn ok(self) -> Option<T>

Converts from TracedResult<T, E> to Option<T>, emitting any tracing entry in the process.

Trait Implementations§

Source§

impl<T, O> Extract<O> for Traced<T>
where T: Try<Output = O>,

Calling any of the extraction functions will emit the enclosed tracing entries related to the relevant variant.

Source§

fn output(self) -> Option<T>

Extracts the contained value v returning Some(v), or None in the case of a Residual Read more
Source§

fn unwrap(self) -> T
where Self::Residual: Debug,

Return the contained value or panic with a generic message. Read more
Source§

fn expect(self, msg: &str) -> T
where Self::Residual: Debug,

Return the contained value or panic with a custom message. Read more
Source§

fn unwrap_or(self, default: T) -> T

Return the contained value or the given default. Read more
Source§

fn unwrap_or_default(self) -> T
where T: Default,

Return the contained value or a default. Requires T to implement Default Read more
Source§

fn unwrap_or_else<F>(self, f: F) -> T
where F: FnOnce() -> T,

Return the contained value or a value computed from a closure.
Source§

impl<T: Try> FromResidual for Traced<T>

§Note

  • The Traced<T> returned from try { Traced<T>? } will have no attached tracing events, as all will be emitted by the ? inside the try block
  • FromResidual is primarily implemented as a formality, normal usage will likely be in the form try bikeshed T { Traced<T>? }
Source§

fn from_residual(residual: <Self as Try>::Residual) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
Source§

impl<T, O> Transform<O> for Traced<T>
where T: Try<Output = O>,

Calling any of the transformation functions will emit the enclosed tracing entries related to the relevant variant.

Source§

fn flatten(self) -> T
where T: FromResidual<Self::Residual>,

Removes one level of nesting, converting Foo<Foo<U>> to Foo<U> or from Foo<Bar<U>> to Bar<U> if suitable residual inter-conversion is implemented.
Source§

fn inspect<F>(self, f: F) -> Self
where F: FnOnce(&T),

Calls a function with a reference to the contained value in the output case. Returns the original Self
Source§

fn map<X, U, F>(self, f: F) -> X
where F: FnOnce(T) -> U, X: Try<Output = U> + FromResidual<Self::Residual>, Self::Residual: Residual<U, TryType = X>,

Applies a function to the contained value (in the ouput case) converting T -> U, leaving residual cases untouched, then returns the canonical TryType for Self with Output U.
Source§

fn map_or<U, F>(self, default: U, f: F) -> U
where F: FnOnce(T) -> U,

Applies a function to the contained value (in the output case) converting T -> U, or returns the given default value. Read more
Source§

fn map_or_else<U, D, F>(self, default: D, f: F) -> U
where D: FnOnce() -> U, F: FnOnce(T) -> U,

Applies a function to the contained value (in the output case) converting T -> U, or returns the result of default(). Read more
Source§

fn map_residual<F, X, G>(self, f: F) -> X
where F: FnOnce(Self::Residual) -> G, G: Residual<T, TryType = X>, X: Try<Output = T> + FromResidual<G>,

Applies a function to the residual, leaving output values untouched, then returns the canonical TryType for the residual returned by the function (and Output T). Read more
Source§

fn transpose<X>(self) -> X
where T: Try, X: Try + FromResidual<<T as Try>::Residual>, <X as Try>::Output: Try<Output = <T as Try>::Output> + FromResidual<Self::Residual>, <T as Try>::Residual: Residual<<X as Try>::Output, TryType = X>, Self::Residual: Residual<<T as Try>::Output, TryType = <X as Try>::Output>,

Converts from a Foo<Bar<U>> to a Bar<Foo<U>> where both Foo & Bar are Try. Read more
Source§

fn zip<X, Y>(self, other: Y) -> X
where Y: Try, X: Try<Output = (T, <Y as Try>::Output)> + FromResidual<Self::Residual> + FromResidual<<Y as Try>::Residual>, Self::Residual: Residual<<X as Try>::Output, TryType = X>,

foo.zip(bar) combines a Foo<T> with a Bar<U> into a Foo<(T,U)> where residual interconversion is available from Bar->Foo. Returns the canonical TryType based upon Foo. Returns a residual if either Foo or Bar are residuals. Read more
Source§

fn zip_with<X, Y, F, G>(self, other: Y, f: F) -> X
where Y: Try, F: FnOnce(T, <Y as Try>::Output) -> G, X: Try<Output = G> + FromResidual<Self::Residual> + FromResidual<<Y as Try>::Residual>, Self::Residual: Residual<G, TryType = X>,

foo.zip_with(bar, do_stuff) applies do_stuff(foo?, bar?) to the combined values inside Foo<T> & Bar<U> where residual interconversion is available from Bar->Foo. Returns the canonical TryType based upon Foo. Read more
Source§

fn and<Y>(self, other: Y) -> Y
where Y: Try<Output = T> + FromResidual<Self::Residual>,

foo.and(bar) returns bar if foo is the output case, otherwise returns foo. Read more
Source§

fn and_then<Y, F, U>(self, f: F) -> Y
where Y: Try<Output = U> + FromResidual<Self::Residual>, F: FnOnce(T) -> Y,

foo.and_then(bar) calls bar() if foo is the output case, otherwise returns foo.
Source§

fn or<Y>(self, other: Y) -> Y
where Y: Try<Output = T>,

foo.or(bar) will return a Bar<T> wrapping the contents of foo if foo is the output case or bar if foo is a residual. Read more
Source§

fn or_else<Y, F>(self, f: F) -> Y
where Y: Try<Output = T>, F: FnOnce(Self::Residual) -> Y,

foo.or_else(bar) where bar is a function returning a Bar<T> will return a Bar<T> wrapping the contents of foo if foo is the output case or call bar(foo) if foo is a residual. Read more
Source§

impl<T: Try> Try for Traced<T>

§Note

  • Any attached events are emitted when branch is called and all wrappings are removed, leaving either the Output or Resdiual of the wrapped Try-type. For example: using ? on a Traced<Traced<Option<T>>> will result in either a T or None.
  • Traced<T> does not implement its own Output or Residual types but immediately unwraps to the Output / Residual of the wrapped Try-type.
Source§

fn branch(self) -> ControlFlow<Self::Residual, Self::Output>

🔬This is a nightly-only experimental API. (try_trait_v2)

Used in ? to decide whether the operator should produce a value (because this returned ControlFlow::Continue) or propagate a value back to the caller (because this returned ControlFlow::Break).

§Note

Any attached events are emitted when branch is called and all wrappings are removed, leaving either the Output or Resdiual of the wrapped Try-type. For example: using ? on a Traced<Traced<Option<T>>> will result in either a T or None.

Source§

type Output = <T as Try>::Output

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value produced by ? when not short-circuiting.
Source§

type Residual = <T as Try>::Residual

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value passed to FromResidual::from_residual as part of ? when short-circuiting. Read more
Source§

fn from_output(output: Self::Output) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from its Output type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Traced<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Traced<T>
where T: RefUnwindSafe,

§

impl<T> Send for Traced<T>
where T: Send,

§

impl<T> Sync for Traced<T>
where T: Sync,

§

impl<T> Unpin for Traced<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Traced<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Traced<T>
where T: UnwindSafe,

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> Trace<T> for T
where T: Try,

Source§

fn or_error(self, name: &'static str) -> Traced<T>

Attaches an error-level message to the Residual case.
Source§

fn and_error(self, name: &'static str) -> Traced<T>

Attaches an error-level message to the Output case.
Source§

fn or_warn(self, name: &'static str) -> Traced<T>

Attaches a warning message to the Residual case.
Source§

fn and_warn(self, name: &'static str) -> Traced<T>

Attaches a warning message to the Output case.
Source§

fn or_info(self, name: &'static str) -> Traced<T>

Attaches an info message to the Residual case.
Source§

fn and_info(self, name: &'static str) -> Traced<T>

Attaches an info message to the Output case.
Source§

fn or_debug(self, name: &'static str) -> Traced<T>

Attaches a debug message to the Residual case.
Source§

fn and_debug(self, name: &'static str) -> Traced<T>

Attaches a debug message to the Output case.
Source§

fn or_trace(self, name: &'static str) -> Traced<T>

Attaches a trace-level message to the Residual case.
Source§

fn and_trace(self, name: &'static str) -> Traced<T>

Attaches a trace-level message to the Output case.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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