use crate::core::AnyInfo;
use crate::{UniqueId, Weight};
pub type ActionBox = Box<dyn ActionDispatcher>;
#[derive(Eq, PartialEq, Hash)]
pub struct ActionKey {
action_type_id: UniqueId,
referer_type_id: Option<UniqueId>,
referer_id: Option<String>,
}
impl ActionKey {
pub fn new(
action_type_id: UniqueId,
referer_type_id: Option<UniqueId>,
referer_id: Option<String>,
) -> Self {
ActionKey {
action_type_id,
referer_type_id,
referer_id,
}
}
}
pub trait ActionDispatcher: AnyInfo + Send + Sync {
fn referer_type_id(&self) -> Option<UniqueId> {
None
}
fn referer_id(&self) -> Option<String> {
None
}
fn weight(&self) -> Weight {
0
}
}