use core::fmt::Debug;
use crate::port::{event_id::EventId, notifier::Notifier, notifier::NotifierCreateError};
use iceoryx2_log::fail;
use crate::service;
use super::event::PortFactory;
#[derive(Debug, Clone)]
pub struct PortFactoryNotifier<'factory, Service: service::Service> {
pub(crate) factory: &'factory PortFactory<Service>,
default_event_id: EventId,
}
unsafe impl<Service: service::Service> Send for PortFactoryNotifier<'_, Service> {}
impl<'factory, Service: service::Service> PortFactoryNotifier<'factory, Service> {
pub(crate) fn new(factory: &'factory PortFactory<Service>) -> Self {
Self {
factory,
default_event_id: EventId::default(),
}
}
pub fn default_event_id(mut self, value: EventId) -> Self {
self.default_event_id = value;
self
}
pub fn create(self) -> Result<Notifier<Service>, NotifierCreateError> {
Ok(
fail!(from self, when Notifier::new(self.factory.service.clone(), self.default_event_id),
"Failed to create new Notifier port."),
)
}
}