[−][src]Struct inkling::Story
Story with knots, diverts, choices and possibly lots of text.
Methods
impl Story
[src]
pub fn start(
&mut self,
line_buffer: &mut LineBuffer
) -> Result<Prompt, InklingError>
[src]
&mut self,
line_buffer: &mut LineBuffer
) -> Result<Prompt, InklingError>
Start walking through the story while reading all lines into the supplied buffer.
Returns either when the story reached an end or when a set of choices was encountered,
which requires the user to select one. Continue the story with resume_with_choice
.
Notes
The input line buffer is not cleared before reading new lines into it.
Examples
let content = "\ Only in silence the word, only in dark the light, only in dying life: bright the hawk’s flight on the empty sky. "; let mut story: Story = read_story_from_string(content).unwrap(); let mut line_buffer = Vec::new(); story.start(&mut line_buffer); assert_eq!(line_buffer.last().unwrap().text, "on the empty sky.\n");
pub fn resume_with_choice(
&mut self,
choice: &Choice,
line_buffer: &mut LineBuffer
) -> Result<Prompt, InklingError>
[src]
&mut self,
choice: &Choice,
line_buffer: &mut LineBuffer
) -> Result<Prompt, InklingError>
Resume the story with a choice from the given set.
The story continues until it reaches a dead end or another set of choices is encountered.
Notes
The input line buffer is not cleared before reading new lines into it.
Examples
let content = "\ Just as Nancy picked the old diary up from the table she heard the door behind her creak open. Someone’s coming! * She spun around to face the danger head on. Her heart was racing as the door slowly swung open and the black cat from the garden swept in. “Miao!” * In one smooth motion she hid behind the large curtain. A familiar “meow” coming from the room filled her with relief. That barely lasted a moment before the dusty curtains made her sneeze, awakening the house keeper sleeping in the neighbouring room. "; let mut story = read_story_from_string(content).unwrap(); let mut line_buffer = Vec::new(); if let Prompt::Choice(choices) = story.start(&mut line_buffer).unwrap() { story.resume_with_choice(&choices[0], &mut line_buffer); } assert_eq!(line_buffer.last().unwrap().text, "“Miao!”\n");
Trait Implementations
Auto Trait Implementations
impl !Sync for Story
impl Unpin for Story
impl Send for Story
impl !UnwindSafe for Story
impl !RefUnwindSafe for Story
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,