mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Extend prepare API/docs across bindings
Agent-Logs-Url: https://github.com/microsoft/regorus/sessions/49ba4462-95d3-42c0-a302-db1b81df4f65 Co-authored-by: anakrish <35780660+anakrish@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
72515f6d4c
commit
730e6de75a
@@ -199,6 +199,21 @@ pub extern "C" fn regorus_engine_clone(engine: *mut RegorusEngine) -> *mut Regor
|
||||
}
|
||||
}
|
||||
|
||||
/// Prepare a [`RegorusEngine`] for evaluation without executing a query.
|
||||
///
|
||||
/// This is optional. If not called, first eval performs the same setup.
|
||||
/// If policy/data changes after preparation, setup is invalidated.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn regorus_engine_prepare(engine: *mut RegorusEngine) -> RegorusResult {
|
||||
with_unwind_guard(|| {
|
||||
to_regorus_result(|| -> Result<()> {
|
||||
let engine = to_ref(engine)?;
|
||||
let mut guard = engine.try_write()?;
|
||||
guard.prepare()
|
||||
}())
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn regorus_engine_drop(engine: *mut RegorusEngine) {
|
||||
if let Ok(e) = to_ref(engine) {
|
||||
|
||||
Reference in New Issue
Block a user