Add feature guards in event::error
Previously, this code assumed all experimental features were enabled in
grid-sdk and did not properly guard specific ones. After this change,
only error From associated with the correct features are compiled.
use std::error::Error;
use std::fmt;
-use grid_sdk::{
- commits::store::CommitStoreError, location::store::LocationStoreError,
- pike::store::PikeStoreError, product::store::ProductStoreError,
- schema::store::SchemaStoreError, track_and_trace::store::TrackAndTraceStoreError,
-};
+use grid_sdk::commits::store::CommitStoreError;
+#[cfg(feature = "location")]
+use grid_sdk::location::store::LocationStoreError;
+#[cfg(feature = "pike")]
+use grid_sdk::pike::store::PikeStoreError;
+#[cfg(feature = "product")]
+use grid_sdk::product::store::ProductStoreError;
+#[cfg(feature = "schema")]
+use grid_sdk::schema::store::SchemaStoreError;
+#[cfg(feature = "track-and-trace")]
+use grid_sdk::track_and_trace::store::TrackAndTraceStoreError;
#[derive(Debug)]
pub struct EventProcessorError(pub String);
@@ -52,30 +58,35 @@ impl From<CommitStoreError> for EventError {
}
}
+#[cfg(feature = "location")]
impl From<LocationStoreError> for EventError {
fn from(err: LocationStoreError) -> Self {
EventError(format!("{}", err))
}
}
+#[cfg(feature = "pike")]
impl From<PikeStoreError> for EventError {
fn from(err: PikeStoreError) -> Self {
EventError(format!("{}", err))
}
}
+#[cfg(feature = "product")]
impl From<ProductStoreError> for EventError {
fn from(err: ProductStoreError) -> Self {
EventError(format!("{}", err))
}
}
+#[cfg(feature = "schema")]
impl From<SchemaStoreError> for EventError {
fn from(err: SchemaStoreError) -> Self {
EventError(format!("{}", err))
}
}
+#[cfg(feature = "track-and-trace")]
impl From<TrackAndTraceStoreError> for EventError {
fn from(err: TrackAndTraceStoreError) -> Self {
EventError(format!("{}", err))
