use super::attrs::Attrs;
use super::mark::Mark;
use super::types::NodeId;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Node {
#[serde(rename = "i")]
pub id: NodeId,
#[serde(rename = "t")]
pub r#type: String,
#[serde(rename = "a")]
pub attrs: Attrs,
#[serde(rename = "c")]
pub content: im::Vector<NodeId>, #[serde(rename = "m")]
pub marks: im::Vector<Mark>,
}
unsafe impl Send for Node {}
unsafe impl Sync for Node {}
impl Node {
pub fn new(
id: &str, r#type: String,
attrs: Attrs,
content: Vec<NodeId>,
marks: Vec<Mark>,
) -> Self {
Node {
id: id.into(), r#type,
attrs,
content: content.into(),
marks: marks.into(),
}
}
pub fn child_count(&self) -> usize {
self.content.len()
}
}