cmark_writer/ast/
custom.rs1use crate::error::WriteResult;
4use std::any::Any;
5
6pub trait CustomNode: std::fmt::Debug + Send + Sync {
8 fn write(&self, writer: &mut dyn CustomNodeWriter) -> WriteResult<()>;
10
11 fn clone_box(&self) -> Box<dyn CustomNode>;
13
14 fn eq_box(&self, other: &dyn CustomNode) -> bool;
16
17 fn is_block(&self) -> bool;
19
20 fn as_any(&self) -> &dyn Any;
22}
23
24pub trait CustomNodeWriter {
26 fn write_str(&mut self, s: &str) -> std::fmt::Result;
28
29 fn write_char(&mut self, c: char) -> std::fmt::Result;
31}
32
33impl Clone for Box<dyn CustomNode> {
35 fn clone(&self) -> Self {
36 self.clone_box()
37 }
38}
39
40impl PartialEq for Box<dyn CustomNode> {
42 fn eq(&self, other: &Self) -> bool {
43 self.eq_box(&**other)
44 }
45}