use super::source::Source; #[derive(Debug, PartialEq)] pub enum Object<'s> { RegularLink(RegularLink<'s>), RadioLink(RadioLink<'s>), RadioTarget(RadioTarget<'s>), PlainLink(PlainLink<'s>), AngleLink(AngleLink<'s>), Bold(Bold<'s>), Italic(Italic<'s>), Underline(Underline<'s>), StrikeThrough(StrikeThrough<'s>), Code(Code<'s>), Verbatim(Verbatim<'s>), PlainText(PlainText<'s>), } #[derive(Debug, PartialEq)] pub struct Bold<'s> { pub source: &'s str, pub children: Vec>, } #[derive(Debug, PartialEq)] pub struct Italic<'s> { pub source: &'s str, pub children: Vec>, } #[derive(Debug, PartialEq)] pub struct Underline<'s> { pub source: &'s str, pub children: Vec>, } #[derive(Debug, PartialEq)] pub struct StrikeThrough<'s> { pub source: &'s str, pub children: Vec>, } #[derive(Debug, PartialEq)] pub struct Code<'s> { pub source: &'s str, pub contents: &'s str, } #[derive(Debug, PartialEq)] pub struct Verbatim<'s> { pub source: &'s str, pub contents: &'s str, } #[derive(Debug, PartialEq)] pub struct PlainText<'s> { pub source: &'s str, } #[derive(Debug, PartialEq)] pub struct RegularLink<'s> { pub source: &'s str, } #[derive(Debug, PartialEq)] pub struct RadioTarget<'s> { pub source: &'s str, pub children: Vec>, } #[derive(Debug, PartialEq)] pub struct RadioLink<'s> { pub source: &'s str, pub children: Vec>, } #[derive(Debug, PartialEq)] pub struct PlainLink<'s> { pub source: &'s str, pub link_type: &'s str, pub path: &'s str, } #[derive(Debug, PartialEq)] pub struct AngleLink<'s> { pub source: &'s str, pub link_type: &'s str, pub path: &'s str, } impl<'s> Source<'s> for Object<'s> { fn get_source(&'s self) -> &'s str { match self { Object::Bold(obj) => obj.source, Object::Italic(obj) => obj.source, Object::Underline(obj) => obj.source, Object::StrikeThrough(obj) => obj.source, Object::Code(obj) => obj.source, Object::Verbatim(obj) => obj.source, Object::PlainText(obj) => obj.source, Object::RegularLink(obj) => obj.source, Object::RadioLink(obj) => obj.source, Object::RadioTarget(obj) => obj.source, Object::PlainLink(obj) => obj.source, Object::AngleLink(obj) => obj.source, } } } impl<'s> Source<'s> for Bold<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for Italic<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for Underline<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for StrikeThrough<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for Code<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for Verbatim<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for RegularLink<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for RadioLink<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for RadioTarget<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for PlainLink<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for AngleLink<'s> { fn get_source(&'s self) -> &'s str { self.source } }