apalis_board_types/
lib.rs

1#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
2use serde::{Deserialize, Serialize};
3
4/// Configuration module.
5pub mod config;
6
7/// The log level of a log entry.
8#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
9#[serde(rename_all = "UPPERCASE")]
10pub enum LogLevel {
11    /// An informational level for general information.
12    Info,
13    /// A warning level for potential issues.
14    Warn,
15    /// An error level for serious issues.
16    Error,
17    /// Debug level for detailed debugging information.
18    #[default]
19    Debug,
20    /// Trace level for detailed tracing information.
21    Trace,
22}
23
24/// A log entry.
25#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
26pub struct LogEntry {
27    /// An optional tracing span associated with the log entry.
28    pub span: Option<Span>,
29    /// The log level of the entry.
30    pub level: LogLevel,
31    /// The timestamp of the log entry.
32    pub timestamp: String,
33    /// The target of the log entry.
34    pub target: String,
35    /// The main content of the log entry.
36    #[serde(rename = "fields")]
37    pub entry: Entry,
38}
39
40/// A line entry.
41#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
42#[serde(rename_all = "camelCase")]
43pub struct LineEntry {
44    /// The log target.
45    #[serde(rename = "log.target")]
46    pub log_target: String,
47    /// The module path of the log.
48    #[serde(rename = "log.module_path")]
49    pub log_module_path: String,
50    /// The file where the log was generated.
51    #[serde(rename = "log.file")]
52    pub log_file: String,
53    /// The line number in the file where the log was generated.
54    #[serde(rename = "log.line")]
55    pub log_line: i64,
56}
57
58/// Additional information about a log entry.
59#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum EntryType {
62    /// A result entry.
63    Result(ResultEntry),
64    /// A line entry.
65    Line(LineEntry),
66}
67
68/// A result entry.
69#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
70
71pub struct ResultEntry {
72    /// The time taken to complete the task.
73    pub done_in: String,
74    /// The result of the task.
75    pub result: String,
76}
77
78/// A log entry.
79#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
80
81pub struct Entry {
82    /// The log message.
83    pub message: Option<String>,
84    /// Additional entry type information.
85    #[serde(flatten)]
86    pub entry_type: Option<EntryType>,
87}
88
89/// Information about a tracing span.
90#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
91#[serde(rename_all = "camelCase")]
92pub struct Span {
93    /// The unique identifier for the span.
94    pub attempt: i64,
95    /// The task ID associated with the span.
96    pub task_id: String,
97    /// The name of the span.
98    pub name: String,
99}
100
101/// An enumeration of possible API errors.
102#[derive(Debug, thiserror::Error, Serialize, Deserialize)]
103#[serde(tag = "type", content = "message")]
104pub enum ApiError {
105    /// Error related to codec operations.
106    #[error("Codec error: {0}")]
107    CodecError(String),
108    /// Error related to backend operations.
109    #[error("Backend error: {0}")]
110    BackendError(String),
111}