use std::sync::Arc;
use lingara_dialogue_ir::DialogueIr;
use super::GraphState;
use crate::dialogue::graph::Step;
impl GraphState {
pub fn end_on(&mut self, outcome: &str) -> Option<Step> {
if self.ended() {
return None;
}
self.outcome = Some(outcome.to_owned());
Some(Step::Ended { outcome: outcome.to_owned(), checkpoint: self.current().id.clone(), edge: None, trace: None })
}
pub fn rebase(&mut self, ir: Arc<DialogueIr>, checkpoint: &str) -> bool {
let Some(at) = ir.checkpoints.iter().position(|c| c.id == checkpoint) else { return false };
(self.ir, self.checkpoint) = (ir, at);
true
}
}