musli_core/en/encode_trace.rs
1use super::Encoder;
2
3/// Trait governing how types are encoded specifically for tracing.
4///
5/// This is used for types where some extra bounds might be necessary to trace a
6/// container such as a [`HashMap<K, V>`] where `K` would have to implement
7/// [`fmt::Display`].
8///
9/// [`HashMap<K, V>`]: std::collections::HashMap
10/// [`fmt::Display`]: std::fmt::Display
11pub trait EncodeTrace<M> {
12 /// Encode the given output.
13 fn trace_encode<E>(&self, encoder: E) -> Result<(), E::Error>
14 where
15 E: Encoder<Mode = M>;
16
17 /// The number of fields in the type.
18 #[inline]
19 fn size_hint(&self) -> Option<usize> {
20 None
21 }
22}