#![forbid(missing_docs)]
use std::future::Future;
mod context;
mod future;
mod obj_utils;
mod registry;
mod root;
mod spawn;
pub use context::*;
pub use future::*;
pub use registry::*;
pub use root::*;
pub use spawn::*;
#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord)]
pub struct Span(flexstr::SharedStr);
impl Span {
pub(crate) fn as_str(&self) -> &str {
self.0.as_str()
}
}
impl<S: AsRef<str>> From<S> for Span {
fn from(value: S) -> Self {
Self(flexstr::SharedStr::from_ref(value))
}
}
impl std::fmt::Display for Span {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
pub trait InstrumentAwait: Future + Sized {
fn instrument_await(self, span: impl Into<Span>) -> Instrumented<Self, false> {
Instrumented::new(self, span.into())
}
fn verbose_instrument_await(self, span: impl Into<Span>) -> Instrumented<Self, true> {
Instrumented::new(self, span.into())
}
}
impl<F> InstrumentAwait for F where F: Future {}
#[cfg(test)]
mod tests;