1use core::fmt;
11
12use crate::record::Record;
13
14pub trait Format: Send + Sync {
21 fn write_record<W: fmt::Write + ?Sized>(
32 &self,
33 record: &Record<'_>,
34 writer: &mut W,
35 ) -> fmt::Result;
36}
37
38impl<T: Format + ?Sized> Format for &T {
40 fn write_record<W: fmt::Write + ?Sized>(
41 &self,
42 record: &Record<'_>,
43 writer: &mut W,
44 ) -> fmt::Result {
45 (**self).write_record(record, writer)
46 }
47}
48
49#[cfg(feature = "std")]
50impl<T: Format + ?Sized> Format for std::sync::Arc<T> {
51 fn write_record<W: fmt::Write + ?Sized>(
52 &self,
53 record: &Record<'_>,
54 writer: &mut W,
55 ) -> fmt::Result {
56 (**self).write_record(record, writer)
57 }
58}
59
60#[cfg(feature = "std")]
61impl<T: Format + ?Sized> Format for Box<T> {
62 fn write_record<W: fmt::Write + ?Sized>(
63 &self,
64 record: &Record<'_>,
65 writer: &mut W,
66 ) -> fmt::Result {
67 (**self).write_record(record, writer)
68 }
69}
70
71#[cfg(any(feature = "json", feature = "human"))]
72pub(crate) mod rfc3339;
73
74#[cfg(feature = "json")]
75mod json;
76#[cfg(feature = "json")]
77pub use self::json::JsonFormat;
78
79#[cfg(feature = "logfmt")]
80mod logfmt;
81#[cfg(feature = "logfmt")]
82pub use self::logfmt::LogfmtFormat;
83
84#[cfg(feature = "human")]
85mod human;
86#[cfg(feature = "human")]
87pub use self::human::HumanFormat;