tracing_modality/common/
mod.rs

1pub(crate) mod ingest;
2pub(crate) mod layer;
3pub(crate) mod options;
4
5#[cfg(doc)]
6use crate::Options;
7use ingest::{ConnectError, TimelineId};
8use std::fmt::Debug;
9use thiserror::Error;
10
11#[derive(Debug, Error)]
12pub enum InitError {
13    /// No auth was provided, set with
14    /// [`Options::set_auth`][crate::Options::set_auth]/[`Options::with_auth`][crate::Options::with_auth]
15    /// or set the `MODALITY_AUTH_TOKEN` environment variable.
16    #[error("Authentication required, set init option or env var MODALITY_AUTH_TOKEN")]
17    AuthRequired,
18
19    /// Auth was provided, but was not accepted by modality.
20    #[error(transparent)]
21    AuthFailed(ConnectError),
22
23    /// Errors that it is assumed there is no way to handle without human intervention, meant for
24    /// consumers to just print and carry on or panic.
25    #[error(transparent)]
26    UnexpectedFailure(#[from] anyhow::Error),
27}
28
29/// Retrieve the current local timeline ID. Useful for for sending alongside data and a custom nonce
30/// for recording timeline interactions on remote timelines.
31pub fn timeline_id() -> TimelineId {
32    ingest::current_timeline()
33}