返回 CodeWhale
composition_review.rs
根目录 / crates / plugins / src / composition_review.rs
1 use std::sync::OnceLock;
2
3 use serde_json::Value;
4
5 pub type CompositionReviewFn = fn(&Value) -> Result<Value, String>;
6
7 static REVIEWER: OnceLock<CompositionReviewFn> = OnceLock::new();
8
9 pub fn install_composition_reviewer(reviewer: CompositionReviewFn) {
10 let _ = REVIEWER.set(reviewer);
11 }
12
13 pub fn review(input: &Value) -> Result<Value, String> {
14 let reviewer = REVIEWER
15 .get()
16 .ok_or_else(|| "composition reviewer is unavailable".to_string())?;
17 reviewer(input)
18 }
19
19 lines RUST