diff --git a/apps/cli/src/domains/file.rs b/apps/cli/src/domains/file.rs
index 246b15bc5..17664fae5 100644
--- a/apps/cli/src/domains/file.rs
+++ b/apps/cli/src/domains/file.rs
@@ -58,7 +58,7 @@ pub async fn run(ctx: &Context, cmd: FileCmd) -> Result<()> {
if let Err(errors) = input.validate() {
anyhow::bail!(errors.join("; "))
}
- ctx.core.action(&input).await?;
+ let _bytes = ctx.core.action(&input).await?;
println!("Copy request submitted");
}
}
diff --git a/apps/cli/src/main.rs b/apps/cli/src/main.rs
index f90154e08..15a5744fc 100644
--- a/apps/cli/src/main.rs
+++ b/apps/cli/src/main.rs
@@ -131,7 +131,7 @@ async fn main() -> Result<()> {
if let Err(errors) = input.validate() {
anyhow::bail!(errors.join("; "));
}
- core.action(&input).await?;
+ let _bytes = core.action(&input).await?;
println!("Copy request submitted");
}
}
diff --git a/apps/graphql/src/main.rs b/apps/graphql/src/main.rs
index 46ad9b4d3..cf9f7ea9c 100644
--- a/apps/graphql/src/main.rs
+++ b/apps/graphql/src/main.rs
@@ -59,7 +59,7 @@ impl MutationRoot {
let mut input = sd_core::ops::files::copy::input::FileCopyInput::default();
input.sources = sources.into_iter().map(Into::into).collect();
input.destination = destination.into();
- state
+ let _bytes = state
.core
.action(&input)
.await
diff --git a/core/src/client/mod.rs b/core/src/client/mod.rs
index e1529f79e..1dfee1745 100644
--- a/core/src/client/mod.rs
+++ b/core/src/client/mod.rs
@@ -23,7 +23,7 @@ impl CoreClient {
}
}
- pub async fn action(&self, action: &A) -> Result<()>
+ pub async fn action(&self, action: &A) -> Result>
where
A: Wire + Serialize,
{
@@ -37,7 +37,7 @@ impl CoreClient {
.await;
match resp {
Ok(r) => match r {
- DaemonResponse::Ok(_) => Ok(()),
+ DaemonResponse::Ok(bytes) => Ok(bytes),
DaemonResponse::Error(e) => Err(anyhow::anyhow!(e)),
other => Err(anyhow::anyhow!(format!("unexpected response: {:?}", other))),
},
diff --git a/core/src/infra/job/handle.rs b/core/src/infra/job/handle.rs
index 52c09f7a3..246f30d67 100644
--- a/core/src/infra/job/handle.rs
+++ b/core/src/infra/job/handle.rs
@@ -103,6 +103,16 @@ impl JobHandle {
}
}
+// Serialize JobHandle as its JobId for wire transport
+impl serde::Serialize for JobHandle {
+ fn serialize(&self, serializer: S) -> Result
+ where
+ S: serde::Serializer,
+ {
+ self.id.serialize(serializer)
+ }
+}
+
/// Update events from a job
#[derive(Debug)]
pub enum JobUpdate {
diff --git a/core/src/ops/registry.rs b/core/src/ops/registry.rs
index 64d70af0e..ec0a9e361 100644
--- a/core/src/ops/registry.rs
+++ b/core/src/ops/registry.rs
@@ -113,9 +113,10 @@ pub fn handle_library_action(
where
A: crate::infra::action::LibraryAction + 'static,
A::Input: DeserializeOwned + 'static,
+ A::Output: serde::Serialize + 'static,
{
use bincode::config::standard;
- use bincode::serde::decode_from_slice;
+ use bincode::serde::{decode_from_slice, encode_to_vec};
(async move {
let input: A::Input = decode_from_slice(&payload, standard())
.map_err(|e| e.to_string())?
@@ -123,11 +124,11 @@ where
let action = A::from_input(input)?;
let manager = crate::infra::action::manager::ActionManager::new(core.context.clone());
let library_id = session.current_library_id.ok_or("No library selected")?;
- manager
+ let out = manager
.dispatch_library(library_id, action)
.await
.map_err(|e| e.to_string())?;
- Ok(Vec::new())
+ encode_to_vec(&out, standard()).map_err(|e| e.to_string())
})
.boxed_local()
}
@@ -141,20 +142,21 @@ pub fn handle_core_action(
where
A: crate::infra::action::CoreAction + 'static,
A::Input: DeserializeOwned + 'static,
+ A::Output: serde::Serialize + 'static,
{
use bincode::config::standard;
- use bincode::serde::decode_from_slice;
+ use bincode::serde::{decode_from_slice, encode_to_vec};
(async move {
let input: A::Input = decode_from_slice(&payload, standard())
.map_err(|e| e.to_string())?
.0;
let action = A::from_input(input)?;
let manager = crate::infra::action::manager::ActionManager::new(core.context.clone());
- manager
+ let out = manager
.dispatch_core(action)
.await
.map_err(|e| e.to_string())?;
- Ok(Vec::new())
+ encode_to_vec(&out, standard()).map_err(|e| e.to_string())
})
.boxed_local()
}