Skip to content

Commit

Permalink
Compilation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed May 10, 2023
1 parent 1679891 commit 0e05194
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/re_sdk/src/msg_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ pub enum FromFileError {
#[error(transparent)]
MsgSender(#[from] MsgSenderError),

#[cfg(feature = "image")]
#[error(transparent)]
TensorImageLoad(#[from] re_log_types::component_types::TensorImageLoadError),

#[cfg(not(target_arch = "wasm32"))]
#[error("Unsupported file extension '{extension}' for file {path:?}. To load image files, make sure you compile with the 'image' feature")]
UnknownExtension {
extension: String,
path: std::path::PathBuf,
},
}

/// Facilitates building and sending component payloads with the Rerun SDK.
Expand Down Expand Up @@ -158,12 +166,19 @@ impl MsgSender {
"glft" => load_mesh(ent_path, crate::components::MeshFormat::Gltf),
"obj" => load_mesh(ent_path, crate::components::MeshFormat::Obj),

// Assume and image (there are so many image extensions)
#[cfg(feature = "image")]
_ => {
// Assume and image (there are so many image extensions):
let tensor = re_log_types::component_types::Tensor::from_image_file(file_path)?;
let msg_sender = Self::new(ent_path).with_component(&[tensor])?;
Ok(msg_sender)
}

#[cfg(not(feature = "image"))]
_ => Err(FromFileError::UnknownExtension {
extension,
path: file_path.to_owned(),
}),
}
}

Expand Down

0 comments on commit 0e05194

Please sign in to comment.