#[cfg(feature = "use_serde")]
use serde::{Deserialize, Serialize};
#[derive(PartialEq, Eq, Clone, Debug)]
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
pub enum Line {
Scene(String),
Action(String),
Dialogue(String),
Speaker { name: String, is_dual: bool },
Parenthetical(String),
Transition(String),
Lyric(String),
}
impl Line {
pub fn is_scene(&self) -> bool {
if let Line::Scene(_) = self {
true
} else {
false
}
}
pub fn is_dialogue(&self) -> bool {
if let Line::Dialogue(_) = self {
true
} else {
false
}
}
pub fn is_action(&self) -> bool {
if let Line::Action(_) = self {
true
} else {
false
}
}
pub fn is_speaker(&self) -> bool {
if let Line::Speaker { .. } = self {
true
} else {
false
}
}
pub fn is_parenthetical(&self) -> bool {
if let Line::Parenthetical(_) = self {
true
} else {
false
}
}
pub fn is_transition(&self) -> bool {
if let Line::Transition(_) = self {
true
} else {
false
}
}
pub fn is_lyric(&self) -> bool {
if let Line::Lyric(_) = self {
true
} else {
false
}
}
}
#[derive(PartialEq, Eq, Clone, Debug, Default)]
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
pub struct TitlePage {
pub author: Option<String>,
pub title: Option<String>,
pub other: Vec<(String, String)>,
}
#[derive(PartialEq, Eq, Clone, Debug, Default)]
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
pub struct Document {
pub lines: Vec<Line>,
pub titlepage: TitlePage,
}