pub fn validate_rust_source(code: &str) -> Result<(), ExecutionError>Expand description
Validate that user source code fits the phase 1 bounded source model.
The phase 1 model requires self-contained snippets that provide
fn run(input: Value) -> Value. The harness supplies fn main(),
use serde_json::Value;, and links serde_json. User code must not
redefine main or use crate-level attributes.
Returns Ok(()) if the code passes validation, or
Err(ExecutionError::InvalidRequest(...)) with a descriptive message.
§Example
use adk_code::validate_rust_source;
// Valid: provides the run() contract
assert!(validate_rust_source(r#"
fn run(input: serde_json::Value) -> serde_json::Value {
input
}
"#).is_ok());
// Invalid: defines fn main()
assert!(validate_rust_source(r#"
fn main() { println!("hello"); }
"#).is_err());