2023-03-23 21:51:49 +00:00
|
|
|
use super::source::Source;
|
2023-03-23 21:02:08 +00:00
|
|
|
|
2023-03-23 21:26:07 +00:00
|
|
|
#[derive(Debug)]
|
2023-03-23 20:49:52 +00:00
|
|
|
pub enum Object<'s> {
|
2023-04-03 19:15:16 +00:00
|
|
|
#[allow(dead_code)]
|
2023-03-23 20:49:52 +00:00
|
|
|
TextMarkup(TextMarkup<'s>),
|
2023-04-03 19:15:16 +00:00
|
|
|
|
2023-03-23 20:49:52 +00:00
|
|
|
PlainText(PlainText<'s>),
|
2023-04-03 19:15:16 +00:00
|
|
|
|
|
|
|
#[allow(dead_code)]
|
2023-03-23 21:02:08 +00:00
|
|
|
RegularLink(RegularLink<'s>),
|
2023-03-23 20:49:52 +00:00
|
|
|
}
|
|
|
|
|
2023-03-23 21:26:07 +00:00
|
|
|
#[derive(Debug)]
|
2023-03-23 20:49:52 +00:00
|
|
|
pub struct TextMarkup<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-03-23 21:26:07 +00:00
|
|
|
#[derive(Debug)]
|
2023-03-23 20:49:52 +00:00
|
|
|
pub struct PlainText<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-03-23 21:26:07 +00:00
|
|
|
#[derive(Debug)]
|
2023-03-23 21:02:08 +00:00
|
|
|
pub struct RegularLink<'s> {
|
|
|
|
pub source: &'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 {
|
|
|
|
Object::TextMarkup(obj) => obj.source,
|
|
|
|
Object::PlainText(obj) => obj.source,
|
2023-03-23 21:02:08 +00:00
|
|
|
Object::RegularLink(obj) => obj.source,
|
2023-03-23 20:49:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|