moduforge_runtime/helpers/create_doc.rs
1use std::sync::Arc;
2
3use moduforge_core::model::node_pool::NodePool;
4
5use crate::types::Content;
6
7/// 创建文档
8pub fn create_doc(content: &Content) -> Option<Arc<NodePool>> {
9 let doc = match content {
10 Content::NodePool(node_pool) => Some(Arc::new(node_pool.clone())),
11 Content::None => None,
12 };
13 if let Some(doc) = &doc {
14 if let Err(err) = doc.validate_hierarchy() {
15 panic!("{}", err);
16 }
17 }
18 doc
19}