|
@@ -35,6 +35,82 @@ pub enum Level {
|
|
|
Trace,
|
|
|
}
|
|
|
|
|
|
+macro_rules! impl_formatter_for_types {
|
|
|
+ ($trait:path : { $($type:ty),*}) => {
|
|
|
+ $(
|
|
|
+ impl $trait for $type {}
|
|
|
+ )*
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+// Any value impl `ToString`
|
|
|
+pub trait DefaultFormatter {}
|
|
|
+impl_formatter_for_types!(
|
|
|
+ DefaultFormatter: {
|
|
|
+ bool,
|
|
|
+ i8, i16, i32, i64, isize,
|
|
|
+ u8, u16, u32, u64, usize,
|
|
|
+ f32, f64,
|
|
|
+ char,
|
|
|
+ str,
|
|
|
+ &str
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
+pub trait LowerHexFormatter {}
|
|
|
+impl_formatter_for_types!(
|
|
|
+ LowerHexFormatter: {
|
|
|
+ i8, i16, i32, i64, isize,
|
|
|
+ u8, u16, u32, u64, usize
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
+pub trait LowerHexDebugFormatter {}
|
|
|
+impl LowerHexDebugFormatter for &[u8] {}
|
|
|
+
|
|
|
+pub trait UpperHexFormatter {}
|
|
|
+impl_formatter_for_types!(
|
|
|
+ UpperHexFormatter: {
|
|
|
+ i8, i16, i32, i64, isize,
|
|
|
+ u8, u16, u32, u64, usize
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
+pub trait UpperHexDebugFormatter {}
|
|
|
+impl UpperHexDebugFormatter for &[u8] {}
|
|
|
+
|
|
|
+pub trait Ipv4Formatter {}
|
|
|
+impl Ipv4Formatter for u32 {}
|
|
|
+
|
|
|
+pub trait Ipv6Formatter {}
|
|
|
+impl Ipv6Formatter for [u8; 16] {}
|
|
|
+impl Ipv6Formatter for [u16; 8] {}
|
|
|
+
|
|
|
+pub trait LowerMacFormatter {}
|
|
|
+impl LowerMacFormatter for [u8; 6] {}
|
|
|
+
|
|
|
+pub trait UpperMacFormatter {}
|
|
|
+impl UpperMacFormatter for [u8; 6] {}
|
|
|
+
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_default<T: DefaultFormatter>(_v: T) {}
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_lower_hex<T: LowerHexFormatter>(_v: T) {}
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_lower_hex_debug<T: LowerHexDebugFormatter>(_v: T) {}
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_upper_hex<T: UpperHexFormatter>(_v: T) {}
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_upper_hex_debug<T: UpperHexDebugFormatter>(_v: T) {}
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_ipv4<T: Ipv4Formatter>(_v: T) {}
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_ipv6<T: Ipv6Formatter>(_v: T) {}
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_lower_mac<T: LowerMacFormatter>(_v: T) {}
|
|
|
+#[inline(always)]
|
|
|
+pub fn check_impl_upper_mac<T: UpperMacFormatter>(_v: T) {}
|
|
|
+
|
|
|
#[repr(u8)]
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
pub enum RecordField {
|