use crate::{story::Story, story_error::StoryError};
impl Story {
pub(crate) fn reset_callstack(&mut self) -> Result<(), StoryError> {
self.if_async_we_cant("ResetCallstack")?;
self.get_state_mut().force_end();
Ok(())
}
pub fn switch_flow(&mut self, flow_name: &str) -> Result<(), StoryError> {
self.if_async_we_cant("switch flow")?;
if self.async_saving {
return Err(StoryError::InvalidStoryState(format!(
"Story is already in background saving mode, can't switch flow to {}",
flow_name
)));
}
self.get_state_mut().switch_flow_internal(flow_name);
Ok(())
}
pub fn remove_flow(&mut self, flow_name: &str) -> Result<(), StoryError> {
self.get_state_mut().remove_flow_internal(flow_name)
}
pub fn switch_to_default_flow(&mut self) {
self.get_state_mut().switch_to_default_flow_internal();
}
}