organic/src/parser/object.rs

39 lines
740 B
Rust
Raw Normal View History

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)]
pub enum Object<'s> {
2023-04-03 19:15:16 +00:00
#[allow(dead_code)]
TextMarkup(TextMarkup<'s>),
2023-04-03 19:15:16 +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 21:26:07 +00:00
#[derive(Debug)]
pub struct TextMarkup<'s> {
pub source: &'s str,
2023-04-22 23:34:13 +00:00
pub children: Vec<Object<'s>>,
}
2023-03-23 21:26:07 +00:00
#[derive(Debug)]
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,
}
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,
}
}
}