Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bryevdv committed Oct 20, 2023
1 parent d043690 commit c28219e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ pub fn start(mut data_sources: Vec<Box<dyn DeferredDataSource>>) {
env_logger::try_init().unwrap_or(()); // Log to stderr (if you run with `RUST_LOG=debug`).

let app_name = if data_sources.len() == 1 {
match data_sources[0].get_description().source_locator {
match data_sources[0].fetch_description().source_locator {
Some(source_locator) => source_locator,
_ => String::from("Legion Prof"),
}
Expand Down
22 changes: 4 additions & 18 deletions src/deferred_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use crate::data::{
};

pub trait DeferredDataSource {
fn fetch_description(&mut self);
fn get_description(&mut self) -> DataSourceDescription;
fn fetch_description(&mut self) -> DataSourceDescription;
fn fetch_info(&mut self);
fn get_infos(&mut self) -> Vec<DataSourceInfo>;
fn fetch_summary_tile(&mut self, entry_id: &EntryID, tile_id: TileID, full: bool);
Expand Down Expand Up @@ -37,9 +36,7 @@ impl<T: DataSourceMut> DeferredDataSourceWrapper<T> {
}

impl<T: DataSourceMut> DeferredDataSource for DeferredDataSourceWrapper<T> {
fn fetch_description(&mut self) {}

fn get_description(&mut self) -> DataSourceDescription {
fn fetch_description(&mut self) -> DataSourceDescription {
self.data_source.fetch_description()
}

Expand Down Expand Up @@ -111,17 +108,10 @@ impl<T: DeferredDataSource> CountingDeferredDataSource<T> {
}

impl<T: DeferredDataSource> DeferredDataSource for CountingDeferredDataSource<T> {
fn fetch_description(&mut self) {
self.start_request();
fn fetch_description(&mut self) -> DataSourceDescription {
self.data_source.fetch_description()
}

fn get_description(&mut self) -> DataSourceDescription {
let result = self.data_source.get_description();
self.outstanding_requests -= 1;
result
}

fn fetch_info(&mut self) {
self.start_request();
self.data_source.fetch_info()
Expand Down Expand Up @@ -165,14 +155,10 @@ impl<T: DeferredDataSource> DeferredDataSource for CountingDeferredDataSource<T>
}

impl DeferredDataSource for Box<dyn DeferredDataSource> {
fn fetch_description(&mut self) {
fn fetch_description(&mut self) -> DataSourceDescription {
self.as_mut().fetch_description()
}

fn get_description(&mut self) -> DataSourceDescription {
self.as_mut().get_description()
}

fn fetch_info(&mut self) {
self.as_mut().fetch_info()
}
Expand Down
2 changes: 1 addition & 1 deletion src/file_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl FileDataSource {
impl DataSource for FileDataSource {
fn fetch_description(&self) -> DataSourceDescription {
DataSourceDescription {
source_locator: None,
source_locator: Some(String::from(self.basedir.to_string_lossy())),
}
}
fn fetch_info(&self) -> DataSourceInfo {
Expand Down
6 changes: 2 additions & 4 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ impl HTTPClientDataSource {
}

impl DeferredDataSource for HTTPClientDataSource {
fn fetch_description(&mut self) {}

fn get_description(&mut self) -> DataSourceDescription {
fn fetch_description(&mut self) -> DataSourceDescription {
DataSourceDescription {
source_locator: None,
source_locator: Some(self.baseurl.to_string()),
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/parallel_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ impl<T: DataSource + Send + Sync + 'static> ParallelDeferredDataSource<T> {
}

impl<T: DataSource + Send + Sync + 'static> DeferredDataSource for ParallelDeferredDataSource<T> {
fn fetch_description(&mut self) {}

fn get_description(&mut self) -> DataSourceDescription {
fn fetch_description(&mut self) -> DataSourceDescription {
self.data_source.fetch_description()
}

Expand Down

0 comments on commit c28219e

Please sign in to comment.