Skip to main content

usage/spec/
admonition.rs

1use serde::Serialize;
2
3/// The significance of a structured explanatory block.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
5#[serde(rename_all = "snake_case")]
6pub enum SpecAdmonitionKind {
7    Note,
8    Warning,
9}
10
11/// A note or warning whose presentation is chosen by the renderer.
12#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
13pub struct SpecAdmonition {
14    pub kind: SpecAdmonitionKind,
15    pub text: String,
16}
17
18impl SpecAdmonition {
19    pub fn note(text: impl Into<String>) -> Self {
20        Self {
21            kind: SpecAdmonitionKind::Note,
22            text: text.into(),
23        }
24    }
25
26    pub fn warning(text: impl Into<String>) -> Self {
27        Self {
28            kind: SpecAdmonitionKind::Warning,
29            text: text.into(),
30        }
31    }
32}