2023-03-23 17:51:49 -04:00
|
|
|
use super::source::Source;
|
2023-03-23 17:02:08 -04:00
|
|
|
|
2023-03-23 17:26:07 -04:00
|
|
|
#[derive(Debug)]
|
2023-03-23 16:49:52 -04:00
|
|
|
pub enum Object<'s> {
|
2023-04-03 15:15:16 -04:00
|
|
|
#[allow(dead_code)]
|
2023-03-23 16:49:52 -04:00
|
|
|
TextMarkup(TextMarkup<'s>),
|
2023-04-03 15:15:16 -04:00
|
|
|
|
2023-03-23 16:49:52 -04:00
|
|
|
PlainText(PlainText<'s>),
|
2023-04-03 15:15:16 -04:00
|
|
|
|
|
|
|
#[allow(dead_code)]
|
2023-03-23 17:02:08 -04:00
|
|
|
RegularLink(RegularLink<'s>),
|
2023-03-23 16:49:52 -04:00
|
|
|
}
|
|
|
|
|
2023-03-23 17:26:07 -04:00
|
|
|
#[derive(Debug)]
|
2023-03-23 16:49:52 -04:00
|
|
|
pub struct TextMarkup<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-03-23 17:26:07 -04:00
|
|
|
#[derive(Debug)]
|
2023-03-23 16:49:52 -04:00
|
|
|
pub struct PlainText<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-03-23 17:26:07 -04:00
|
|
|
#[derive(Debug)]
|
2023-03-23 17:02:08 -04:00
|
|
|
pub struct RegularLink<'s> {
|
|
|
|
pub source: &'s str,
|
2023-03-23 16:49:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'s> Source<'s> for Object<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
match self {
|
|
|
|
Object::TextMarkup(obj) => obj.source,
|
|
|
|
Object::PlainText(obj) => obj.source,
|
2023-03-23 17:02:08 -04:00
|
|
|
Object::RegularLink(obj) => obj.source,
|
2023-03-23 16:49:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|