pub mod external {
pub use prost;
}
mod v0 {
#![allow(clippy::all, clippy::pedantic, clippy::nursery)]
#[path = "./rerun.common.v0.rs"]
pub mod rerun_common_v0;
#[path = "./rerun.log_msg.v0.rs"]
pub mod rerun_log_msg_v0;
#[path = "./rerun.remote_store.v0.rs"]
pub mod rerun_remote_store_v0;
}
pub mod common {
pub mod v0 {
pub use crate::v0::rerun_common_v0::*;
}
}
pub mod log_msg {
pub mod v0 {
pub use crate::v0::rerun_log_msg_v0::*;
}
}
pub mod remote_store {
pub mod v0 {
pub use crate::v0::rerun_remote_store_v0::*;
}
}
#[derive(Debug, thiserror::Error)]
pub enum TypeConversionError {
#[error("missing required field: {package_name}.{type_name}.{field_name}")]
MissingField {
package_name: &'static str,
type_name: &'static str,
field_name: &'static str,
},
#[error("invalid value for field {package_name}.{type_name}.{field_name}: {reason}")]
InvalidField {
package_name: &'static str,
type_name: &'static str,
field_name: &'static str,
reason: String,
},
#[error("failed to decode: {0}")]
DecodeError(#[from] prost::DecodeError),
#[error("failed to encode: {0}")]
EncodeError(#[from] prost::EncodeError),
#[error("{0}")]
UnknownEnumValue(#[from] prost::UnknownEnumValue),
}
impl TypeConversionError {
#[inline]
pub fn missing_field<T: prost::Name>(field_name: &'static str) -> Self {
Self::MissingField {
package_name: T::PACKAGE,
type_name: T::NAME,
field_name,
}
}
#[allow(clippy::needless_pass_by_value)] #[inline]
pub fn invalid_field<T: prost::Name>(field_name: &'static str, reason: &impl ToString) -> Self {
Self::InvalidField {
package_name: T::PACKAGE,
type_name: T::NAME,
field_name,
reason: reason.to_string(),
}
}
}
#[macro_export]
macro_rules! missing_field {
($type:ty, $field:expr $(,)?) => {
$crate::TypeConversionError::missing_field::<$type>($field)
};
}
#[macro_export]
macro_rules! invalid_field {
($type:ty, $field:expr, $reason:expr $(,)?) => {
$crate::TypeConversionError::invalid_field::<$type>($field, &$reason)
};
}