use crate::{FXAttributes, FXPubMode};
pub trait FXTriggerHelper {
fn is_true(&self) -> bool;
}
pub trait FXFrom<T> {
fn fx_from(value: T) -> Self;
}
pub trait FXInto<T> {
fn fx_into(self) -> T;
}
pub trait FXBoolHelper {
fn is_true(&self) -> bool;
fn is_true_opt(&self) -> Option<bool>;
fn not_true(&self) -> bool {
!self.is_true()
}
}
pub trait FXHelperTrait: FXTriggerHelper {
fn name(&self) -> Option<&str>;
fn public_mode(&self) -> Option<FXPubMode>;
fn attributes(&self) -> Option<&FXAttributes>;
fn attributes_fn(&self) -> Option<&FXAttributes>;
}
impl<T, U> FXInto<U> for T
where
U: FXFrom<T>,
{
#[inline]
fn fx_into(self) -> U {
U::fx_from(self)
}
}
impl<H: FXTriggerHelper> FXBoolHelper for Option<H> {
#[inline]
fn is_true(&self) -> bool {
self.as_ref().map_or(false, |h| h.is_true())
}
#[inline]
fn is_true_opt(&self) -> Option<bool> {
self.as_ref().map(|h| h.is_true())
}
}