Skip to main content

brooks_lib/cdni/logging/
spec.rs

1// brooks, Copyright 2026, Will Hawkins
2//
3// This file is part of brooks.
4
5// This file is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17
18//! Logging (and related) metadata definitions
19
20use crate::macros::IntoCdniMetadata;
21use brooks_macros::CdniMetadata;
22
23use serde::{Deserialize, Serialize};
24use serde_json::Value;
25
26use std::fmt::Debug;
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub enum LoggingContainerType {
30    #[serde(rename = "json_v1")]
31    JsonV1,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct LoggingContainerMetadata {
36    #[serde(rename = "container-type")]
37    pub container_type: LoggingContainerType,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub enum LoggingRecordType {
42    #[serde(rename = "opencaching_minimal_json_v1")]
43    MinimalJsonV1,
44    #[serde(rename = "opencaching_standard_json_v1")]
45    StandardJsonV1,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub enum LoggingTransportType {
50    #[serde(rename = "MI.LoggingTransportKafka")]
51    Kafka,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct LoggingTransport {
56    #[serde(rename = "transport-type")]
57    pub transport_type: LoggingTransportType,
58    #[serde(rename = "record-type")]
59    pub record_type: LoggingRecordType,
60    #[serde(rename = "container-metadata")]
61    pub container_metadata: LoggingContainerMetadata,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct LoggingMetadata<A: Debug + Clone + Default> {
66    pub transports: Vec<LoggingTransport>,
67
68    #[serde(skip)]
69    pub aug: A,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize, CdniMetadata)]
73pub struct TypedLoggingMetadata<A: Debug + Clone + Default> {
74    #[serde(rename = "generic-metadata-type")]
75    pub tpe: String,
76    #[serde(rename = "generic-metadata-value")]
77    pub value: LoggingMetadata<A>,
78}