Skip to content

Commit

Permalink
SmartChannelSource::Files -> SmartChannelSource::File
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Aug 28, 2023
1 parent eb28b68 commit 578c0e7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 28 deletions.
7 changes: 3 additions & 4 deletions crates/re_smart_channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ pub use sender::Sender;
/// receiving end.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum SmartChannelSource {
/// The channel was created in the context of loading a bunch of files from disk (could be
/// The channel was created in the context of loading a file from disk (could be
/// `.rrd` files, or `.glb`, `.png`, …).
// TODO(#2121): Remove this
Files { paths: Vec<std::path::PathBuf> },
File { path: std::path::PathBuf },

/// The channel was created in the context of loading an `.rrd` file over http.
RrdHttpStream { url: String },
Expand Down Expand Up @@ -59,7 +58,7 @@ pub enum SmartChannelSource {
impl SmartChannelSource {
pub fn is_network(&self) -> bool {
match self {
Self::Files { .. } | Self::Sdk | Self::RrdWebEventListener => false,
Self::File { .. } | Self::Sdk | Self::RrdWebEventListener => false,
Self::RrdHttpStream { .. } | Self::WsClient { .. } | Self::TcpServer { .. } => true,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ impl App {
match &*source {
// These source are typically "finite". We want the loading screen so long as data is
// coming in.
SmartChannelSource::Files { .. } | SmartChannelSource::RrdHttpStream { .. } => {
SmartChannelSource::File { .. } | SmartChannelSource::RrdHttpStream { .. } => {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn recording_config_entry<'cfgs>(
match data_source {
// Play files from the start by default - it feels nice and alive./
// RrdHttpStream downloads the whole file before decoding it, so we treat it the same as a file.
re_smart_channel::SmartChannelSource::Files { .. }
re_smart_channel::SmartChannelSource::File { .. }
| re_smart_channel::SmartChannelSource::RrdHttpStream { .. }
| re_smart_channel::SmartChannelSource::RrdWebEventListener => PlayState::Playing,

Expand Down
10 changes: 4 additions & 6 deletions crates/re_viewer/src/loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ pub fn load_file_path(path: &std::path::Path, with_notifications: bool) -> Optio
re_log::info!("Loaded {path:?}");
}
for store_db in rrd.store_dbs_mut() {
store_db.data_source = Some(re_smart_channel::SmartChannelSource::Files {
paths: vec![path.into()],
});
store_db.data_source =
Some(re_smart_channel::SmartChannelSource::File { path: path.into() });
}
Some(rrd)
}
Expand All @@ -44,9 +43,8 @@ pub fn load_file_contents(name: &str, read: impl std::io::Read) -> Option<StoreB
Ok(mut rrd) => {
re_log::info!("Loaded {name:?}");
for store_db in rrd.store_dbs_mut() {
store_db.data_source = Some(re_smart_channel::SmartChannelSource::Files {
paths: vec![name.into()],
});
store_db.data_source =
Some(re_smart_channel::SmartChannelSource::File { path: name.into() });
}
Some(rrd)
}
Expand Down
16 changes: 4 additions & 12 deletions crates/re_viewer/src/ui/wait_screen_ui.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use egui::{Ui, Widget};
use itertools::Itertools;

use re_log_types::LogMsg;
use re_smart_channel::{ReceiveSet, SmartChannelSource};

use re_ui::ReUi;

const MIN_COLUMN_WIDTH: f32 = 250.0;
Expand Down Expand Up @@ -324,16 +323,9 @@ fn status_strings(rx: &ReceiveSet<LogMsg>) -> Vec<StatusStrings> {

fn status_string(source: &SmartChannelSource) -> StatusStrings {
match source {
re_smart_channel::SmartChannelSource::Files { paths } => StatusStrings::new(
"Loading…",
format!(
"{}",
paths
.iter()
.format_with(", ", |path, f| f(&format_args!("{}", path.display()))),
),
false,
),
re_smart_channel::SmartChannelSource::File { path } => {
StatusStrings::new("Loading…", path.display().to_string(), false)
}
re_smart_channel::SmartChannelSource::RrdHttpStream { url } => {
StatusStrings::new("Loading…", url.clone(), false)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/viewer_analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl ViewerAnalytics {

if let Some(data_source) = &store_db.data_source {
let data_source = match data_source {
re_smart_channel::SmartChannelSource::Files { .. } => "file", // .rrd, .png, .glb, …
re_smart_channel::SmartChannelSource::File { .. } => "file", // .rrd, .png, .glb, …
re_smart_channel::SmartChannelSource::RrdHttpStream { .. } => "http",
re_smart_channel::SmartChannelSource::RrdWebEventListener { .. } => "web_event",
re_smart_channel::SmartChannelSource::Sdk => "sdk", // show()
Expand Down
4 changes: 1 addition & 3 deletions crates/rerun/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,7 @@ fn stream_data_source(data_source: DataSource) -> anyhow::Result<Receiver<LogMsg
DataSource::FilePath(path) => {
let (tx, rx) = re_smart_channel::smart_channel(
re_smart_channel::SmartMessageSource::File(path.clone()),
re_smart_channel::SmartChannelSource::Files {
paths: vec![path.clone()],
},
re_smart_channel::SmartChannelSource::File { path: path.clone() },
);
let store_id = re_log_types::StoreId::random(re_log_types::StoreKind::Recording);
load_file_to_channel_at(store_id, &path, tx).with_context(|| format!("{path:?}"))?;
Expand Down

0 comments on commit 578c0e7

Please sign in to comment.