pub mod message_queue;
pub mod posix_shared_memory;
pub mod process_local;
pub mod unix_datagram;
use std::fmt::Debug;
use iceoryx2_bb_posix::config::TEMP_DIRECTORY;
use iceoryx2_bb_system_types::file_name::FileName;
use iceoryx2_bb_system_types::path::Path;
use crate::named_concept::{NamedConcept, NamedConceptBuilder, NamedConceptMgmt};
pub const DEFAULT_RECEIVER_BUFFER_SIZE: usize = 8;
pub const DEFAULT_SUFFIX: FileName = unsafe { FileName::new_unchecked(b".com") };
pub const DEFAULT_PREFIX: FileName = unsafe { FileName::new_unchecked(b"iox2_") };
pub const DEFAULT_PATH_HINT: Path = TEMP_DIRECTORY;
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
pub enum CommunicationChannelSendError {
ConnectionBroken,
MessageTooLarge,
ReceiverCacheIsFull,
InternalFailure,
}
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
pub enum CommunicationChannelReceiveError {
ConnectionBroken,
MessageCorrupt,
InternalFailure,
}
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
pub enum CommunicationChannelCreateError {
AlreadyExists,
SafeOverflowNotSupported,
CustomBufferSizeNotSupported,
InternalFailure,
}
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
pub enum CommunicationChannelOpenError {
InternalFailure,
AnotherInstanceIsAlreadyConnected,
DoesNotExist,
}
pub trait CommunicationChannelCreator<T, C: CommunicationChannel<T> + Sized>:
NamedConceptBuilder<C>
{
fn enable_safe_overflow(self) -> Self;
fn buffer_size(self, value: usize) -> Self;
fn create_receiver(self) -> Result<C::Receiver, CommunicationChannelCreateError>;
}
pub trait CommunicationChannelConnector<T, C: CommunicationChannel<T> + Sized>:
NamedConceptBuilder<C>
{
fn open_sender(self) -> Result<C::Sender, CommunicationChannelOpenError>;
fn try_open_sender(self) -> Result<C::Sender, CommunicationChannelOpenError>;
}
pub trait CommunicationChannelParticipant {
fn does_enable_safe_overflow(&self) -> bool;
}
pub trait CommunicationChannelSender<T>:
Debug + CommunicationChannelParticipant + NamedConcept
{
fn send(&self, data: &T) -> Result<Option<T>, CommunicationChannelSendError>;
fn try_send(&self, data: &T) -> Result<Option<T>, CommunicationChannelSendError>;
}
pub trait CommunicationChannelReceiver<T>:
Debug + CommunicationChannelParticipant + NamedConcept
{
fn buffer_size(&self) -> usize;
fn receive(&self) -> Result<Option<T>, CommunicationChannelReceiveError>;
}
pub trait CommunicationChannel<T>: Sized + Debug + NamedConceptMgmt {
type Sender: CommunicationChannelSender<T>;
type Receiver: CommunicationChannelReceiver<T>;
type Creator: CommunicationChannelCreator<T, Self>;
type Connector: CommunicationChannelConnector<T, Self>;
fn does_support_safe_overflow() -> bool {
false
}
fn has_configurable_buffer_size() -> bool {
false
}
}