From c5a137f2f6d97fb2657366dfe6874d768814c4c2 Mon Sep 17 00:00:00 2001 From: Lut99 Date: Wed, 6 Nov 2024 15:00:03 +0100 Subject: [PATCH] Removed `State` from the EFlintJsonReasoner --- examples/eflint_json.rs | 9 +++++---- lib/reasoners/eflint-json/src/reasonerconn.rs | 17 ++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/examples/eflint_json.rs b/examples/eflint_json.rs index ac1e31f..aa9a8ae 100644 --- a/examples/eflint_json.rs +++ b/examples/eflint_json.rs @@ -4,7 +4,7 @@ // Created: // 10 Oct 2024, 13:54:17 // Last edited: -// 17 Oct 2024, 12:07:02 +// 06 Nov 2024, 14:59:22 // Auto updated? // Yes // @@ -18,11 +18,12 @@ use std::path::PathBuf; use clap::Parser; use console::style; +use eflint_json_reasoner::json::spec::Phrase; use error_trace::trace; use policy_reasoner::loggers::file::FileLogger; use policy_reasoner::reasoners::eflint_json::json::spec::RequestPhrases; use policy_reasoner::reasoners::eflint_json::reasons::EFlintSilentReasonHandler; -use policy_reasoner::reasoners::eflint_json::{EFlintJsonReasonerConnector, State}; +use policy_reasoner::reasoners::eflint_json::EFlintJsonReasonerConnector; use policy_reasoner::spec::auditlogger::SessionedAuditLogger; use policy_reasoner::spec::reasonerconn::ReasonerConnector as _; use policy_reasoner::spec::reasons::NoReason; @@ -181,7 +182,7 @@ async fn main() { }; // Create the reasoner - let conn = match EFlintJsonReasonerConnector::::new_async( + let conn = match EFlintJsonReasonerConnector::, ()>::new_async( &args.address, EFlintSilentReasonHandler, &mut logger, @@ -194,7 +195,7 @@ async fn main() { std::process::exit(1); }, }; - let verdict: ReasonerResponse = match conn.consult(State { policy: policy.phrases, state: () }, (), &mut logger).await { + let verdict: ReasonerResponse = match conn.consult(policy.phrases, (), &mut logger).await { Ok(res) => res, Err(err) => { error!("{}", trace!(("Failed to send message to reasoner at {:?}", args.address), err)); diff --git a/lib/reasoners/eflint-json/src/reasonerconn.rs b/lib/reasoners/eflint-json/src/reasonerconn.rs index f9f7ed5..1103f8c 100644 --- a/lib/reasoners/eflint-json/src/reasonerconn.rs +++ b/lib/reasoners/eflint-json/src/reasonerconn.rs @@ -4,7 +4,7 @@ // Created: // 09 Oct 2024, 15:52:06 // Last edited: -// 06 Nov 2024, 14:25:12 +// 06 Nov 2024, 14:59:35 // Auto updated? // Yes // @@ -130,15 +130,6 @@ impl spec::context::Context for Context { fn kind(&self) -> &str { "eflint-json" } } -/// Defines the eFLINT reasoner state to submit to it. -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct State { - /// The policy used. - pub policy: Vec, - /// The rest of the state that is appended to the end of the request. - pub state: S, -} - @@ -210,7 +201,7 @@ where type Error = Error; type Question = Q; type Reason = R::Reason; - type State = State; + type State = S; fn consult<'a, L>( &'a self, @@ -229,8 +220,8 @@ where // Build the full policy debug!("Building full policy..."); - let mut phrases: Vec = state.policy; - phrases.extend(state.state.to_eflint().map_err(|err| Error::StateToEFlint { err })?); + let mut phrases: Vec = Vec::new(); + phrases.extend(state.to_eflint().map_err(|err| Error::StateToEFlint { err })?); phrases.extend(question.to_eflint().map_err(|err| Error::QuestionToEFlint { err })?); debug!("Full request length: {} phrase(s)", phrases.len());