2023-03-23 21:51:49 +00:00
|
|
|
use super::source::Source;
|
2023-03-23 21:02:08 +00:00
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-03-23 20:49:52 +00:00
|
|
|
pub enum Object<'s> {
|
2023-04-23 20:53:02 +00:00
|
|
|
RegularLink(RegularLink<'s>),
|
2023-04-24 22:55:15 +00:00
|
|
|
RadioLink(RadioLink<'s>),
|
|
|
|
RadioTarget(RadioTarget<'s>),
|
2023-07-13 22:18:07 +00:00
|
|
|
PlainLink(PlainLink<'s>),
|
2023-07-14 02:42:42 +00:00
|
|
|
AngleLink(AngleLink<'s>),
|
2023-04-23 00:22:07 +00:00
|
|
|
Bold(Bold<'s>),
|
|
|
|
Italic(Italic<'s>),
|
|
|
|
Underline(Underline<'s>),
|
|
|
|
StrikeThrough(StrikeThrough<'s>),
|
|
|
|
Code(Code<'s>),
|
|
|
|
Verbatim(Verbatim<'s>),
|
2023-03-23 20:49:52 +00:00
|
|
|
PlainText(PlainText<'s>),
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-23 00:22:07 +00:00
|
|
|
pub struct Bold<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-23 00:22:07 +00:00
|
|
|
pub struct Italic<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-23 00:22:07 +00:00
|
|
|
pub struct Underline<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-23 00:22:07 +00:00
|
|
|
pub struct StrikeThrough<'s> {
|
2023-03-23 20:49:52 +00:00
|
|
|
pub source: &'s str,
|
2023-04-22 23:34:13 +00:00
|
|
|
pub children: Vec<Object<'s>>,
|
2023-03-23 20:49:52 +00:00
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-23 00:22:07 +00:00
|
|
|
pub struct Code<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub contents: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-23 00:22:07 +00:00
|
|
|
pub struct Verbatim<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub contents: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-03-23 20:49:52 +00:00
|
|
|
pub struct PlainText<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-03-23 21:02:08 +00:00
|
|
|
pub struct RegularLink<'s> {
|
|
|
|
pub source: &'s str,
|
2023-03-23 20:49:52 +00:00
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-24 22:55:15 +00:00
|
|
|
pub struct RadioTarget<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 23:25:22 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-24 22:55:15 +00:00
|
|
|
pub struct RadioLink<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-07-13 22:18:07 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct PlainLink<'s> {
|
|
|
|
pub source: &'s str,
|
2023-07-13 23:09:44 +00:00
|
|
|
pub link_type: &'s str,
|
|
|
|
pub path: &'s str,
|
2023-07-13 22:18:07 +00:00
|
|
|
}
|
|
|
|
|
2023-07-14 02:42:42 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct AngleLink<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub link_type: &'s str,
|
|
|
|
pub path: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-03-23 20:49:52 +00:00
|
|
|
impl<'s> Source<'s> for Object<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
match self {
|
2023-04-23 00:22:07 +00:00
|
|
|
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,
|
2023-03-23 20:49:52 +00:00
|
|
|
Object::PlainText(obj) => obj.source,
|
2023-03-23 21:02:08 +00:00
|
|
|
Object::RegularLink(obj) => obj.source,
|
2023-04-24 22:55:15 +00:00
|
|
|
Object::RadioLink(obj) => obj.source,
|
|
|
|
Object::RadioTarget(obj) => obj.source,
|
2023-07-13 22:18:07 +00:00
|
|
|
Object::PlainLink(obj) => obj.source,
|
2023-07-14 02:42:42 +00:00
|
|
|
Object::AngleLink(obj) => obj.source,
|
2023-03-23 20:49:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-23 00:48:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2023-04-23 20:17:52 +00:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for RegularLink<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-04-24 22:55:15 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2023-07-13 22:18:07 +00:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for PlainLink<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-14 02:42:42 +00:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for AngleLink<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|