MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / new

Method new

guardrail_ffi/src/lib.rs:103–112  ·  view source on GitHub ↗

Load from JSON string.

(json: &str)

Source from the content-addressed store, hash-verified

101impl GuardRailConfig {
102 /// Load from JSON string.
103 pub fn new(json: &str) -> Result<Self, String> {
104 let c_str = CString::new(json).map_err(|e| e.to_string())?;
105 let handle = unsafe { guardrail_config_from_json(c_str.as_ptr(), c_str.as_bytes().len()) };
106 if handle.is_null() {
107 return Err("GuardRail config from_json failed".into());
108 }
109 Ok(Self {
110 inner: Arc::new(GuardRailConfigInner { handle }),
111 })
112 }
113
114 /// Load from file.
115 pub fn from_file(path: &Path) -> Result<Self, String> {

Callers

nothing calls this directly

Calls 2

to_stringMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected