pub(crate) mod call;
mod destination;
pub(crate) mod dispatch;
mod locator;
mod perform;
mod runner;
mod types;
pub use call::ActionCall;
pub(crate) use locator::{
all_elements, call_on, first_element, first_visibility, is_visible, stale, Visibility,
};
pub use locator::{ControlState, Locator};
pub use types::*;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use tokio::sync::{Mutex, OwnedMutexGuard};
#[derive(Default)]
pub(crate) struct ActionState {
pub gate: Arc<Mutex<()>>,
pub cleanup_failed: AtomicBool,
}
impl ActionState {
pub(crate) async fn admit(&self) -> crate::Result<OwnedMutexGuard<()>> {
let gate = self.gate.clone().lock_owned().await;
if self.cleanup_failed.load(Ordering::Acquire) {
return Err(crate::Error::input_state(
"Previous action input cleanup failed; release_all_inputs is required",
));
}
Ok(gate)
}
}