plantuml_parser/dsl/
block.rs

1mod block_comment;
2
3pub use block_comment::BlockComment;
4
5use crate::{ParseContainer, ParseResult};
6
7/// A block of PlantUML
8#[derive(Clone, Debug)]
9pub struct PlantUmlBlock {
10    kind: PlantUmlBlockKind,
11}
12
13/// A kind of PlantUML blocks to be handled by `plantuml-parser`.
14#[derive(Clone, Debug)]
15pub enum PlantUmlBlockKind {
16    /// ```puml
17    /// /' begin comment
18    /// in comment
19    /// end comment '/
20    /// ```
21    BlockComment(BlockComment),
22}
23
24impl PlantUmlBlock {
25    /// Tries to parse [`PlantUmlBlock`].
26    /// NOTE: At the moment, only [`BlockComment`] is handled, so this implementation is specifically tailored for [`BlockComment`].
27    pub fn parse(input: ParseContainer) -> ParseResult<Self> {
28        let (rest, (parsed, comment)) = BlockComment::parse(input)?;
29
30        let ret = Self {
31            kind: PlantUmlBlockKind::BlockComment(comment),
32        };
33        Ok((rest, (parsed, ret)))
34    }
35
36    /// Returns the reference of [`PlantUmlBlockKind`].
37    pub fn kind(&self) -> &PlantUmlBlockKind {
38        &self.kind
39    }
40}