Skip to main content

asimov_telemetry/
lib.rs

1// This is free and unencumbered software released into the public domain.
2
3#![no_std]
4#![forbid(unsafe_code)]
5
6extern crate alloc;
7#[cfg(feature = "std")]
8extern crate std;
9
10use alloc::{string::String, vec::Vec};
11use core::time::Duration;
12use serde::Serialize;
13
14#[cfg(feature = "std")]
15mod client;
16#[cfg(feature = "std")]
17pub use client::{Telemetry, disable, enable, is_disabled};
18
19#[derive(Clone, Copy, Debug, Serialize)]
20#[serde(rename_all = "snake_case")]
21pub enum Operation {
22    Fetch,
23    Read,
24    List,
25}
26
27#[derive(Clone, Copy, Debug, Serialize)]
28#[serde(rename_all = "snake_case")]
29pub enum Outcome {
30    Success,
31    Failure,
32}
33
34#[derive(Clone, Debug)]
35pub enum Event {
36    Installed,
37    CommandStarted {
38        command: String,
39        modules: Vec<String>,
40    },
41    CommandFinished {
42        command: String,
43        modules: Vec<String>,
44        exit_code: i32,
45        duration: Duration,
46    },
47    ModuleOperationFinished {
48        operation: Operation,
49        module: String,
50        outcome: Outcome,
51        duration: Duration,
52    },
53}