Import upstream v0.16.22, stripped
Upstream commit: 474dd0229cb20cf513036619781ed97bd8073c3f Enterprise-only files removed or emptied: 63 Enterprise-only snippets removed: 117 in 50 files Dangling module declarations removed: 5 Cargo edits turning enterprise off: 14 Verification: clean Enterprise feature gates left for rebuilt features: 19 in 18 files Produced by tools/fork/strip.py. The full report is in docs/fork/strip-reports/ on main.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
#![warn(clippy::large_futures)]
|
||||
|
||||
pub mod atomics;
|
||||
pub mod event;
|
||||
pub mod ipc;
|
||||
pub mod macros;
|
||||
pub mod serializers;
|
||||
|
||||
pub use crate::event::enums::*;
|
||||
pub use crate::ipc::collector::Collector;
|
||||
use compact_str::CompactString;
|
||||
pub use event_macro::event;
|
||||
use std::{
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(transparent)]
|
||||
pub struct Error(Box<Event<EventType>>);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Event<T> {
|
||||
pub inner: T,
|
||||
pub keys: Vec<(Key, Value)>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EventDetails {
|
||||
pub typ: EventType,
|
||||
pub timestamp: u64,
|
||||
pub level: Level,
|
||||
pub span: Option<Arc<Event<EventDetails>>>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
#[repr(usize)]
|
||||
pub enum Level {
|
||||
Trace = 0,
|
||||
Debug = 1,
|
||||
Info = 2,
|
||||
Warn = 3,
|
||||
Error = 4,
|
||||
Disable = 5,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub enum Value {
|
||||
String(CompactString),
|
||||
UInt(u64),
|
||||
Int(i64),
|
||||
Float(f64),
|
||||
Timestamp(u64),
|
||||
Duration(u64),
|
||||
Bytes(Vec<u8>),
|
||||
Bool(bool),
|
||||
Ipv4(Ipv4Addr),
|
||||
Ipv6(Ipv6Addr),
|
||||
Event(Error),
|
||||
Array(Vec<Value>),
|
||||
#[default]
|
||||
None,
|
||||
}
|
||||
|
||||
pub trait AddContext<T> {
|
||||
fn caused_by(self, location: &'static str) -> Result<T>;
|
||||
fn add_context<F>(self, f: F) -> Result<T>
|
||||
where
|
||||
F: FnOnce(Error) -> Error;
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
impl Default for MetricType {
|
||||
fn default() -> Self {
|
||||
MetricType::UserCount
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EventType {
|
||||
fn default() -> Self {
|
||||
EventType::Store(StoreEvent::UnexpectedError)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user