use iceoryx2_cal::{
shared_memory::SharedMemoryOpenError, zero_copy_connection::ZeroCopyCreationError,
};
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
pub enum ConnectionFailure {
FailedToEstablishConnection(ZeroCopyCreationError),
UnableToMapSendersDataSegment(SharedMemoryOpenError),
}
impl From<ZeroCopyCreationError> for ConnectionFailure {
fn from(value: ZeroCopyCreationError) -> Self {
ConnectionFailure::FailedToEstablishConnection(value)
}
}
impl From<SharedMemoryOpenError> for ConnectionFailure {
fn from(value: SharedMemoryOpenError) -> Self {
ConnectionFailure::UnableToMapSendersDataSegment(value)
}
}
impl core::fmt::Display for ConnectionFailure {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "ConnectionFailure::{self:?}")
}
}
impl core::error::Error for ConnectionFailure {}
pub trait UpdateConnections {
fn update_connections(&self) -> Result<(), ConnectionFailure>;
}