|
| 1 | +use crate::data::{ |
| 2 | + DataSourceDescription, DataSourceInfo, EntryID, EntryIndex, EntryInfo, Field, ItemLink, |
| 3 | + ItemUID, SlotMetaTile, SlotTile, SummaryTile, TileID, DataSource, |
| 4 | +}; |
| 5 | + |
| 6 | +pub struct StripDataSource<T: DataSource> { |
| 7 | + data_source: T, |
| 8 | +} |
| 9 | + |
| 10 | + |
| 11 | +impl<T: DataSource> StripDataSource<T> { |
| 12 | + pub fn new(data_source: T) -> Self { |
| 13 | + Self { |
| 14 | + data_source, |
| 15 | + } |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +impl<T: DataSource> DataSource for StripDataSource<T> { |
| 20 | + fn fetch_description(&self) -> DataSourceDescription { |
| 21 | + self.data_source.fetch_description() |
| 22 | + } |
| 23 | + |
| 24 | + fn fetch_info(&self) -> DataSourceInfo { |
| 25 | + self.data_source.fetch_info() |
| 26 | + } |
| 27 | + |
| 28 | + fn fetch_summary_tile(&self, entry_id: &EntryID, tile_id: TileID, full: bool) -> SummaryTile { |
| 29 | + self.data_source.fetch_summary_tile(entry_id, tile_id, full) |
| 30 | + } |
| 31 | + |
| 32 | + fn fetch_slot_tile(&self, entry_id: &EntryID, tile_id: TileID, full: bool) -> SlotTile { |
| 33 | + self.data_source.fetch_slot_tile(entry_id, tile_id, full) |
| 34 | + } |
| 35 | + |
| 36 | + fn fetch_slot_meta_tile(&self, entry_id: &EntryID, tile_id: TileID, full: bool) -> SlotMetaTile { |
| 37 | + let mut tile = self.data_source |
| 38 | + .fetch_slot_meta_tile(entry_id, tile_id, full); |
| 39 | + for row in &mut tile.data.items { |
| 40 | + for item in row { |
| 41 | + item.title = "Redacted".to_string(); |
| 42 | + for field in item.fields { |
| 43 | + match field.1 { |
| 44 | + Field::I64(_) => {}, |
| 45 | + Field::U64(_) => {}, |
| 46 | + Field::String(x) => { *x = "Redacted".to_string(); }, |
| 47 | + Field::Interval(_) => {}, |
| 48 | + Field::ItemLink(ItemLink { title, .. }) => { *title = "Redacted".to_string(); }, |
| 49 | + Field::Vec(_) => { todo!() }, |
| 50 | + Field::Empty => {}, |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + tile |
| 56 | + } |
| 57 | +} |
0 commit comments