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