use std::collections::VecDeque;
use std::marker::PhantomData;
use core_types::ActionGoalId;
use crate::message::ActionSchema;
use super::ActionChannel;
mod trait_impl;
pub struct BasicActionServer<G, F, R> {
action_name: String,
schema: ActionSchema,
closed: bool,
channel: Option<std::sync::Arc<ActionChannel<G, F, R>>>,
injected: VecDeque<(ActionGoalId, G)>,
_marker: PhantomData<(G, F, R)>,
}
impl<G, F, R> BasicActionServer<G, F, R> {
pub fn new(action_name: impl Into<String>, schema: ActionSchema) -> Self {
Self {
action_name: action_name.into(),
schema,
closed: false,
channel: None,
injected: VecDeque::new(),
_marker: PhantomData,
}
}
pub fn with_channel(
action_name: impl Into<String>,
schema: ActionSchema,
channel: std::sync::Arc<ActionChannel<G, F, R>>,
) -> Self {
Self {
action_name: action_name.into(),
schema,
closed: false,
channel: Some(channel),
injected: VecDeque::new(),
_marker: PhantomData,
}
}
pub fn inject_goal(&mut self, goal_id: ActionGoalId, goal: G) {
self.injected.push_back((goal_id, goal));
}
}