use std::collections::HashMap;
use serde_json::Value;
use super::ItemOutcome;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum FoldOutcome {
Applied,
Item(ItemOutcome),
Resolution {
first: bool,
},
Ignored,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum TurnState {
Running,
Settled,
Retracted,
Unqueued,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Turn {
pub(super) state: TurnState,
pub(super) command_id: Option<String>,
pub(super) terminal: Option<String>,
pub(super) completion: Option<Value>,
}
impl Turn {
pub const fn state(&self) -> TurnState {
self.state
}
pub fn command_id(&self) -> Option<&str> {
self.command_id.as_deref()
}
pub fn terminal(&self) -> Option<&str> {
self.terminal.as_deref()
}
pub const fn completion(&self) -> Option<&Value> {
self.completion.as_ref()
}
}
#[derive(Debug, Default)]
pub struct SessionState(pub(super) HashMap<String, Value>);
impl SessionState {
pub fn get(&self, family: &str) -> Option<&Value> {
self.0.get(family)
}
pub fn len(&self) -> usize {
self.0.len()
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DeliveryGap {
pub(super) after: String,
pub(super) next: String,
}
impl DeliveryGap {
pub fn after(&self) -> &str {
&self.after
}
pub fn next(&self) -> &str {
&self.next
}
}