git_internal/internal/metadata/
mod.rs1mod entry_meta;
2pub use entry_meta::EntryMeta;
3use std::fmt;
4
5pub trait MetadataExt {
6 type Meta: Clone + std::fmt::Debug + Send + Sync + 'static;
7
8 fn metadata(&self) -> Option<&Self::Meta>;
9 fn metadata_mut(&mut self) -> Option<&mut Self::Meta>;
10 fn set_metadata(&mut self, meta: Self::Meta);
11 }
13
14#[derive(Debug, Clone)]
15pub struct MetaAttached<T, M> {
16 pub inner: T,
17 pub meta: M,
18}
19
20impl<T, M> MetadataExt for MetaAttached<T, M>
21where
22 M: Clone + std::fmt::Debug + Send + Sync + 'static,
23{
24 type Meta = M;
25
26 fn metadata(&self) -> Option<&Self::Meta> {
27 Some(&self.meta)
28 }
29
30 fn metadata_mut(&mut self) -> Option<&mut Self::Meta> {
31 Some(&mut self.meta)
32 }
33
34 fn set_metadata(&mut self, meta: Self::Meta) {
35 self.meta = meta;
36 }
37
38 }
42
43impl<T, M> fmt::Display for MetaAttached<T, M>
44where
45 T: fmt::Display,
46 M: fmt::Debug,
47{
48 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
49 write!(f, "{} | meta: {:?}", self.inner, self.meta)
50 }
51}