Skip to content

Commit 8c987bc

Browse files
StripDataSource.
1 parent 9c86b47 commit 8c987bc

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ pub mod http;
1111
pub mod merge_data;
1212
#[cfg(not(target_arch = "wasm32"))]
1313
pub mod parallel_data;
14+
pub mod strip_data;
1415
pub mod timestamp;

src/strip_data.rs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)