11//! # Defaults Module
22//!
33//! This module provides default implementations for the `PubSubEncoder` and `StreamEncoder` traits.
4- //!
5- //! ## `DefaultPubSubEncoder`
6- //!
7- //! `DefaultPubSubEncoder` is a default implementation of the `PubSubEncoder` trait.
8- //! It encodes a `log::Record` into a JSON object, where each field in the `Record` becomes a key-value pair in the JSON object.
9- //! The JSON object is then converted into a byte vector.
10- //!
11- //! ## `DefaultStreamEncoder`
12- //!
13- //! `DefaultStreamEncoder` is a default implementation of the `StreamEncoder` trait.
14- //! It encodes a `log::Record` into a vector of tuples, where each tuple contains a field name from the `Record` and the
15- //! corresponding value as a byte vector. If a field in the `Record` is `None`, the byte vector is empty.
16- //!
17- //! ## Usage
18- //!
19- //! You can use these default encoders when you don't need to customize the encoding process.
20- //! If you need to customize the encoding, you can implement the `PubSubEncoder` and `StreamEncoder` traits yourself.
214
225use serializable_log_record:: SerializableLogRecord ;
236
247use super :: { PubSubEncoder , Record , StreamEncoder } ;
258
26- /// Default implementation of the `PubSubEncoder` trait converting the incoming `log::Record` into a JSON object.
9+ /// `DefaultPubSubEncoder` is a default implementation of the `PubSubEncoder` trait.
10+ /// It encodes a `log::Record` into a JSON object, where each field in the `Record` becomes a key-value pair in the JSON object.
11+ /// The JSON object is then converted into a byte vector.
12+ ///
13+ /// You can use these default encoders when you don't need to customize the encoding process.
14+ /// If you need to customize the encoding, you can implement the `PubSubEncoder` and `StreamEncoder` traits yourself.
2715#[ derive( Debug ) ]
2816#[ non_exhaustive]
2917pub struct DefaultPubSubEncoder { }
@@ -41,7 +29,12 @@ impl PubSubEncoder for DefaultPubSubEncoder {
4129 }
4230}
4331
44- /// Default implementation of the `StreamEncoder` trait converting the incoming `log::Record` into a vector of tuples of field name and bytes.
32+ /// `DefaultStreamEncoder` is a default implementation of the `StreamEncoder` trait.
33+ /// It encodes a `log::Record` into a vector of tuples, where each tuple contains a field name from the `Record` and the
34+ /// corresponding value as a byte vector. If a field in the `Record` is `None`, the byte vector is empty.
35+ ///
36+ /// You can use these default encoders when you don't need to customize the encoding process.
37+ /// If you need to customize the encoding, you can implement the `PubSubEncoder` and `StreamEncoder` traits yourself.
4538#[ derive( Debug ) ]
4639#[ non_exhaustive]
4740pub struct DefaultStreamEncoder { }
0 commit comments