Skip to content

Commit

Permalink
fix fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-gorules committed Feb 20, 2025
1 parent d88864b commit 614d979
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/uniffi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
extension: "so"
lib_dir: 'linux-aarch64'

name: stable - ${{ matrix.settings.target }} - kotlin@17
name: UniFFI - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}

steps:
Expand Down
4 changes: 2 additions & 2 deletions bindings/uniffi/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use zen_engine::ZEN_CONFIG;

#[derive(uniffi::Record)]
pub struct ZenConfig {
pub nodes_in_context: Option<bool>
pub nodes_in_context: Option<bool>,
}

#[uniffi::export]
pub fn override_config(config: ZenConfig) {
if let Some(val) = config.nodes_in_context {
ZEN_CONFIG.nodes_in_context.store(val, Ordering::Relaxed)
}
}
}
8 changes: 5 additions & 3 deletions bindings/uniffi/src/custom_node.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::error::ZenError;
use crate::types::{DecisionNode, JsonBuffer, ZenEngineHandlerRequest, ZenEngineHandlerResponse};
use crate::types::{DecisionNode, ZenEngineHandlerRequest, ZenEngineHandlerResponse};
use serde_json::Value;
use uniffi::deps::anyhow::anyhow;
use zen_engine::handler::custom_node_adapter::{CustomNodeAdapter, CustomNodeRequest};
use zen_engine::handler::node::{NodeResponse, NodeResult};
use zen_expression::Variable;
use crate::loader::ZenDecisionLoaderCallback;

#[uniffi::export(callback_interface)]
#[async_trait::async_trait]
Expand All @@ -20,7 +19,10 @@ pub struct NoopCustomNodeCallback;

#[async_trait::async_trait]
impl ZenCustomNodeCallback for NoopCustomNodeCallback {
async fn handle(&self, key: ZenEngineHandlerRequest) -> Result<ZenEngineHandlerResponse, ZenError> {
async fn handle(
&self,
key: ZenEngineHandlerRequest,
) -> Result<ZenEngineHandlerResponse, ZenError> {
Err(ZenError::Zero)
}
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/uniffi/src/decision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde_json::Value;
use std::sync::Arc;
use tokio::runtime::Handle;
use tokio::task;
use zen_engine::{Decision, DecisionGraphValidationError, EvaluationOptions};
use zen_engine::{Decision, EvaluationOptions};

#[derive(uniffi::Object)]
pub struct ZenDecision {
Expand Down
20 changes: 5 additions & 15 deletions bindings/uniffi/src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
use crate::custom_node::{NoopCustomNodeCallback, ZenCustomNodeCallback, ZenCustomNodeCallbackWrapper};
use crate::custom_node::{
NoopCustomNodeCallback, ZenCustomNodeCallback, ZenCustomNodeCallbackWrapper,
};
use crate::decision::ZenDecision;
use crate::error::ZenError;
use crate::loader::{
NoopDecisionLoader, ZenDecisionLoaderCallback, ZenDecisionLoaderCallbackWrapper,
};
use crate::types::{
JsonBuffer, ZenEngineHandlerRequest, ZenEngineHandlerResponse, ZenEngineResponse,
};
use async_trait::async_trait;
use crate::types::{JsonBuffer, ZenEngineResponse};
use serde_json::Value;
use std::future::Future;
use std::sync::Arc;
use tokio::runtime::Handle;
use tokio::task;
use uniffi::deps::anyhow::anyhow;
use zen_engine::handler::custom_node_adapter::{
CustomNodeAdapter, CustomNodeRequest, NoopCustomNode,
};
use zen_engine::handler::node::NodeResult;
use zen_engine::loader::{DecisionLoader, NoopLoader};
use zen_engine::model::DecisionContent;
use zen_engine::{DecisionEngine, EvaluationOptions};
use zen_expression::parser::Node;

#[derive(uniffi::Object)]
pub(crate) struct ZenEngine {
Expand Down Expand Up @@ -56,7 +46,7 @@ impl ZenEngine {
loader.unwrap_or_else(|| Box::new(NoopDecisionLoader)),
)),
Arc::new(ZenCustomNodeCallbackWrapper(
custom_node.unwrap_or_else(|| Box::new(NoopCustomNodeCallback))
custom_node.unwrap_or_else(|| Box::new(NoopCustomNodeCallback)),
)),
)),
}
Expand Down
1 change: 0 additions & 1 deletion bindings/uniffi/src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::error::ZenError;
use crate::types::JsonBuffer;
use serde_json::Value;
use tokio::task;
use uniffi::deps::anyhow::anyhow;

#[uniffi::export()]
pub fn evaluate_expression_sync(
Expand Down
8 changes: 4 additions & 4 deletions bindings/uniffi/src/loader.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::error::ZenError;
use crate::types::JsonBuffer;
use std::future::Future;
use std::sync::Arc;
use uniffi::deps::anyhow::anyhow;
use zen_engine::loader::{DecisionLoader, LoaderError, LoaderResponse};
use zen_engine::model::DecisionContent;
use crate::types::JsonBuffer;

#[uniffi::export(callback_interface)]
#[async_trait::async_trait]
Expand Down Expand Up @@ -33,9 +33,9 @@ impl DecisionLoader for ZenDecisionLoaderCallbackWrapper {

let decision_content: DecisionContent = serde_json::from_slice(&maybe_raw.unwrap().0)
.map_err(|e| LoaderError::Internal {
key: key.to_string(),
source: anyhow!(e),
})?;
key: key.to_string(),
source: anyhow!(e),
})?;

Ok(Arc::new(decision_content))
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/uniffi/uniffi-bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main() {
uniffi::uniffi_bindgen_main()
}
}

0 comments on commit 614d979

Please sign in to comment.