use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Code {
Spaces,
Backtick,
Header,
Body,
Flush,
}
impl std::fmt::Display for Code {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Code::Spaces => write!(f, "spaces"),
Code::Backtick => write!(f, "backtick"),
Code::Header => write!(f, "header"),
Code::Body => write!(f, "body"),
Code::Flush => write!(f, "flush"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ListType {
Bullet,
Ordered,
}
impl std::fmt::Display for ListType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ListType::Bullet => write!(f, "bullet"),
ListType::Ordered => write!(f, "ordered"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TableState {
Header,
Body,
}
impl std::fmt::Display for TableState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TableState::Header => write!(f, "header"),
TableState::Body => write!(f, "body"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BlockType {
Quote,
Think,
}
impl std::fmt::Display for BlockType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
BlockType::Quote => write!(f, "quote"),
BlockType::Think => write!(f, "think"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum EmitFlag {
Header1,
Header2,
Flush,
}
impl std::fmt::Display for EmitFlag {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EmitFlag::Header1 => write!(f, "header1"),
EmitFlag::Header2 => write!(f, "header2"),
EmitFlag::Flush => write!(f, "flush"),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_code_display() {
assert_eq!(Code::Spaces.to_string(), "spaces");
assert_eq!(Code::Backtick.to_string(), "backtick");
assert_eq!(Code::Header.to_string(), "header");
assert_eq!(Code::Body.to_string(), "body");
assert_eq!(Code::Flush.to_string(), "flush");
}
#[test]
fn test_list_type_display() {
assert_eq!(ListType::Bullet.to_string(), "bullet");
assert_eq!(ListType::Ordered.to_string(), "ordered");
}
#[test]
fn test_table_state_display() {
assert_eq!(TableState::Header.to_string(), "header");
assert_eq!(TableState::Body.to_string(), "body");
}
#[test]
fn test_block_type_display() {
assert_eq!(BlockType::Quote.to_string(), "quote");
assert_eq!(BlockType::Think.to_string(), "think");
}
#[test]
fn test_emit_flag_display() {
assert_eq!(EmitFlag::Header1.to_string(), "header1");
assert_eq!(EmitFlag::Header2.to_string(), "header2");
assert_eq!(EmitFlag::Flush.to_string(), "flush");
}
}