diff --git a/Cargo.lock b/Cargo.lock index fc7ddf3..20cc46b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -694,6 +694,7 @@ name = "giterated-abi" version = "0.1.0" dependencies = [ "anyhow", + "async-trait", "dlopen2", "giterated-models", ] @@ -744,6 +745,7 @@ dependencies = [ "giterated-models", "giterated-plugin", "giterated-protocol", + "giterated-runtime", "jsonwebtoken", "log", "rand", @@ -857,6 +859,7 @@ name = "giterated-runtime" version = "0.1.0" dependencies = [ "anyhow", + "async-trait", "dlopen2", "giterated-abi", "giterated-core", diff --git a/giterated-core/giterated-models/src/settings/mod.rs b/giterated-core/giterated-models/src/settings/mod.rs index bd3119c..97b1933 100644 --- a/giterated-core/giterated-models/src/settings/mod.rs +++ b/giterated-core/giterated-models/src/settings/mod.rs @@ -1,7 +1,5 @@ mod operations; -use std::{any::Any, sync::Arc}; - pub use operations::*; use serde::{de::DeserializeOwned, Serialize}; diff --git a/giterated-core/giterated-models/src/value.rs b/giterated-core/giterated-models/src/value.rs index 5ca6069..42ead74 100644 --- a/giterated-core/giterated-models/src/value.rs +++ b/giterated-core/giterated-models/src/value.rs @@ -1,7 +1,6 @@ use std::{fmt::Debug, marker::PhantomData}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use serde_json::Value; use crate::{error::GetValueError, object::GiteratedObject, operation::GiteratedOperation}; diff --git a/giterated-core/src/lib.rs b/giterated-core/src/lib.rs index d7777af..7ec4988 100644 --- a/giterated-core/src/lib.rs +++ b/giterated-core/src/lib.rs @@ -7,7 +7,6 @@ use giterated_models::{ }; use std::fmt::Debug; -pub mod operation; pub mod types; #[derive(Clone)] diff --git a/giterated-core/src/operation.rs b/giterated-core/src/operation.rs deleted file mode 100644 index f143c99..0000000 --- a/giterated-core/src/operation.rs +++ /dev/null @@ -1,5 +0,0 @@ -use giterated_abi::value_ex::FfiValueUntyped; - -pub struct Success(FfiValueUntyped); - -pub struct Failure(FfiValueUntyped); diff --git a/giterated-daemon/Cargo.toml b/giterated-daemon/Cargo.toml index 29b6ec2..7274c53 100644 --- a/giterated-daemon/Cargo.toml +++ b/giterated-daemon/Cargo.toml @@ -16,6 +16,7 @@ keywords = ["giterated"] giterated-models = { path = "../giterated-core/giterated-models" } giterated-plugin = { path = "../giterated-plugin" } giterated-protocol = { path = "../plugins/giterated-protocol" } +giterated-runtime = { path = "../giterated-runtime" } tokio-tungstenite = "0.20" tokio = { version = "1.32", features = [ "full" ] } diff --git a/giterated-daemon/src/client.rs b/giterated-daemon/src/client.rs index 7b7e4c0..61479d0 100644 --- a/giterated-daemon/src/client.rs +++ b/giterated-daemon/src/client.rs @@ -1,5 +1,3 @@ -use std::sync::Arc; - use futures_util::{SinkExt, StreamExt}; use giterated_models::{ error::{IntoInternalError, OperationError}, @@ -7,18 +5,18 @@ use giterated_models::{ object_backend::ObjectBackend, operation::OperationState, }; -use giterated_plugin::new_stack::{handle::RuntimeHandle, Runtime}; use giterated_protocol::{ handlers::{NetworkedObject, NetworkedOperation}, AuthenticatedPayload, }; +use giterated_runtime::RuntimeHandle; use tokio::net::TcpStream; use tokio_tungstenite::{tungstenite::Message, WebSocketStream}; pub async fn client_wrapper( _our_instance: Instance, mut socket: WebSocketStream, - _runtime: Arc>, + _runtime: RuntimeHandle, ) { loop { let message = socket.next().await; diff --git a/giterated-daemon/src/main.rs b/giterated-daemon/src/main.rs index bb23a07..2a43c2d 100644 --- a/giterated-daemon/src/main.rs +++ b/giterated-daemon/src/main.rs @@ -3,7 +3,7 @@ use giterated_daemon::{authentication::AuthenticationTokenGranter, client::clien use giterated_models::instance::Instance; -use giterated_plugin::new_stack::Runtime; +use giterated_runtime::{Runtime, RuntimeHandle, StaticRuntimeExt}; use sqlx::{postgres::PgConnectOptions, ConnectOptions, PgPool}; use std::{net::SocketAddr, str::FromStr, sync::Arc}; use tokio::{ @@ -86,9 +86,10 @@ async fn main() -> Result<(), Error> { let our_instance = Instance::from_str(config["giterated"]["instance"].as_str().unwrap()).unwrap(); - let runtime = runtime.clone(); - pool.spawn_pinned(move || client_wrapper(our_instance, connection, runtime)); + pool.spawn_pinned(move || { + client_wrapper(our_instance, connection, RuntimeHandle::from_static()) + }); } } diff --git a/giterated-plugin/giterated-macros/src/lib.rs b/giterated-plugin/giterated-macros/src/lib.rs index cd7f925..953379d 100644 --- a/giterated-plugin/giterated-macros/src/lib.rs +++ b/giterated-plugin/giterated-macros/src/lib.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, Abi, Attribute, ItemFn}; +use syn::{parse_macro_input, ItemFn}; extern crate proc_macro; diff --git a/giterated-plugin/src/future.rs b/giterated-plugin/src/future.rs index 10d0a30..a02ef95 100644 --- a/giterated-plugin/src/future.rs +++ b/giterated-plugin/src/future.rs @@ -7,7 +7,6 @@ use giterated_abi::{ use std::{ cell::UnsafeCell, future::Future, - marker::PhantomData, mem::transmute, ops::Deref, task::{Context, RawWaker, RawWakerVTable, Waker}, @@ -69,7 +68,7 @@ impl RuntimeFuturesExt for State { unsafe extern "C" fn poll_local( _future: FfiValueMut>, - mut future_state: FfiValueMut<()>, + future_state: FfiValueMut<()>, ) -> RuntimeFuturePoll { let mut future_state: FfiValueMut>> = transmute(future_state); diff --git a/giterated-plugin/src/lib.rs b/giterated-plugin/src/lib.rs index 1b3399e..f2aad7a 100644 --- a/giterated-plugin/src/lib.rs +++ b/giterated-plugin/src/lib.rs @@ -7,9 +7,9 @@ pub mod local; pub use giterated_abi as abi; pub use giterated_abi::vtable::{operation::Operation, Object, Setting, Value}; +pub use giterated_abi::operation::*; pub use giterated_abi::state::StateExtractor; pub use giterated_abi::state::{FromState, StateUUID}; -pub use giterated_core::operation::{Failure, Success}; pub use giterated_core::RuntimeState; #[macro_use] diff --git a/giterated-plugin/src/local.rs b/giterated-plugin/src/local.rs index 2650029..4c180e6 100644 --- a/giterated-plugin/src/local.rs +++ b/giterated-plugin/src/local.rs @@ -6,13 +6,11 @@ use giterated_abi::{ Callback, CallbackPtr, }, result::FfiError, - state::{FromState, State, StateUUID}, + state::{State, StateUUID}, value_ex::FfiValueUntyped, vtable::{ - operation::{IntoOperationVTable, OperationVTable}, - plugin_initialization::InitializationVTable, - IntoObjectVTable, IntoSettingVTable, IntoValueVTable, Object, ObjectVTable, SettingVTable, - VTable, ValueVTable, + operation::IntoOperationVTable, plugin_initialization::InitializationVTable, + IntoObjectVTable, IntoSettingVTable, IntoValueVTable, Object, VTable, }, FfiValueMut, FfiValueRef, }; @@ -28,6 +26,12 @@ pub struct PluginStackBuilder { vtable: &'static VTable, } +impl Default for PluginStackBuilder { + fn default() -> Self { + Self::new() + } +} + impl PluginStackBuilder { pub fn new(// state: FfiValueUntyped, // vtable: &'static VTable, diff --git a/giterated-runtime/Cargo.toml b/giterated-runtime/Cargo.toml index 09c5801..29490d6 100644 --- a/giterated-runtime/Cargo.toml +++ b/giterated-runtime/Cargo.toml @@ -12,4 +12,5 @@ giterated-core = { path = "../giterated-core" } tracing = "0.1" dlopen2 = "0.6" -anyhow = "1" \ No newline at end of file +anyhow = "1" +async-trait = "0.1" \ No newline at end of file diff --git a/giterated-runtime/giterated-abi/Cargo.toml b/giterated-runtime/giterated-abi/Cargo.toml index de43792..f9f245f 100644 --- a/giterated-runtime/giterated-abi/Cargo.toml +++ b/giterated-runtime/giterated-abi/Cargo.toml @@ -10,3 +10,4 @@ giterated-models = { path = "../../giterated-core/giterated-models"} anyhow = "1" dlopen2 = "0.6" +async-trait = "0.1" \ No newline at end of file diff --git a/giterated-runtime/giterated-abi/src/callback/setting.rs b/giterated-runtime/giterated-abi/src/callback/setting.rs index 95ed118..561a403 100644 --- a/giterated-runtime/giterated-abi/src/callback/setting.rs +++ b/giterated-runtime/giterated-abi/src/callback/setting.rs @@ -44,7 +44,7 @@ where unsafe extern "C" fn get_setting( callback: CallbackPtr, state: FfiValueMut, - mut object: FfiValueRef, + object: FfiValueRef, ) -> FfiFuture> { // let _guard = trace_span!( // "get_setting handler", @@ -89,7 +89,7 @@ where unsafe extern "C" fn get_setting( callback: CallbackPtr, state: FfiValueMut, - mut object: FfiValueRef, + object: FfiValueRef, ) -> FfiFuture> { todo!() } @@ -119,7 +119,7 @@ where unsafe extern "C" fn set_setting( callback: CallbackPtr, state: FfiValueMut, - mut object: FfiValueRef, + object: FfiValueRef, _setting: Setting, ) -> FfiFuture> { // let _guard = trace_span!( @@ -157,7 +157,7 @@ where unsafe extern "C" fn set_setting( callback: CallbackPtr, state: FfiValueMut, - mut object: FfiValueRef, + object: FfiValueRef, _setting: Setting, ) -> FfiFuture> { todo!() diff --git a/giterated-runtime/giterated-abi/src/callback/value.rs b/giterated-runtime/giterated-abi/src/callback/value.rs index 116d81b..54ed24e 100644 --- a/giterated-runtime/giterated-abi/src/callback/value.rs +++ b/giterated-runtime/giterated-abi/src/callback/value.rs @@ -44,7 +44,7 @@ where unsafe extern "C" fn get_value( callback: CallbackPtr, state: FfiValueMut, - mut object: FfiValueRef, + object: FfiValueRef, ) -> FfiFuture> { // let _guard = trace_span!( // "get_value handler", @@ -94,7 +94,7 @@ where unsafe extern "C" fn get_value( callback: CallbackPtr, state: FfiValueMut, - mut object: FfiValueRef, + object: FfiValueRef, ) -> FfiFuture> { // let _guard = trace_span!( // "get_value handler", diff --git a/giterated-runtime/giterated-abi/src/heap.rs b/giterated-runtime/giterated-abi/src/heap.rs index 1b4e10e..99d4db8 100644 --- a/giterated-runtime/giterated-abi/src/heap.rs +++ b/giterated-runtime/giterated-abi/src/heap.rs @@ -1,4 +1,4 @@ -use std::{mem::MaybeUninit, ptr::drop_in_place}; +use std::mem::MaybeUninit; use crate::{abi_backing::HeapValueBacking, FfiValue}; diff --git a/giterated-runtime/giterated-abi/src/lib.rs b/giterated-runtime/giterated-abi/src/lib.rs index 6772ef0..197e7f0 100644 --- a/giterated-runtime/giterated-abi/src/lib.rs +++ b/giterated-runtime/giterated-abi/src/lib.rs @@ -85,6 +85,7 @@ pub mod callback; mod future; pub mod heap; pub mod model_impl; +pub mod operation; pub mod plugin; pub mod result; pub mod state; diff --git a/giterated-runtime/giterated-abi/src/operation.rs b/giterated-runtime/giterated-abi/src/operation.rs new file mode 100644 index 0000000..20a55c2 --- /dev/null +++ b/giterated-runtime/giterated-abi/src/operation.rs @@ -0,0 +1,5 @@ +use crate::prelude::FfiValueUntyped; + +pub struct Success(FfiValueUntyped); + +pub struct Failure(FfiValueUntyped); diff --git a/giterated-runtime/giterated-abi/src/plugin.rs b/giterated-runtime/giterated-abi/src/plugin.rs index 2bad2c3..1e7047d 100644 --- a/giterated-runtime/giterated-abi/src/plugin.rs +++ b/giterated-runtime/giterated-abi/src/plugin.rs @@ -1,10 +1,6 @@ use dlopen2::wrapper::WrapperApi; -use crate::vtable::{ - plugin::{Plugin, PluginVTable}, - runtime::{RuntimeHandle, RuntimeVTable}, - VTable, -}; +use crate::vtable::{plugin::Plugin, runtime::RuntimeHandle, VTable}; #[derive(WrapperApi)] pub struct GiteratedPluginAbi { diff --git a/giterated-runtime/giterated-abi/src/result.rs b/giterated-runtime/giterated-abi/src/result.rs index c77e6f9..ece1e9c 100644 --- a/giterated-runtime/giterated-abi/src/result.rs +++ b/giterated-runtime/giterated-abi/src/result.rs @@ -1,3 +1,5 @@ +use giterated_models::error::OperationError; + use crate::FfiSlice; #[repr(C)] @@ -10,3 +12,9 @@ pub enum FfiResult { pub struct FfiError { last_error: FfiSlice, } + +impl FfiError { + pub fn into_internal(self) -> OperationError { + todo!() + } +} diff --git a/giterated-runtime/giterated-abi/src/state.rs b/giterated-runtime/giterated-abi/src/state.rs index d33d110..a87f22c 100644 --- a/giterated-runtime/giterated-abi/src/state.rs +++ b/giterated-runtime/giterated-abi/src/state.rs @@ -20,10 +20,7 @@ use giterated_models::error::OperationError; use crate::{ value_ex::FfiValueUntyped, - vtable::{ - runtime::{RuntimeHandle, RuntimeVTable}, - ObjectABI, VTable, - }, + vtable::{runtime::RuntimeHandle, VTable}, }; #[repr(transparent)] diff --git a/giterated-runtime/giterated-abi/src/vtable/operation.rs b/giterated-runtime/giterated-abi/src/vtable/operation.rs index 01c0906..344b96c 100644 --- a/giterated-runtime/giterated-abi/src/vtable/operation.rs +++ b/giterated-runtime/giterated-abi/src/vtable/operation.rs @@ -1,9 +1,10 @@ use std::ffi::CStr; use crate::{ + operation::{Failure, Success}, result::{FfiError, FfiResult}, value_ex::{FfiValueRefUntyped, FfiValueUntyped}, - FfiSlice, FfiSliceRef, FfiValue, FfiValueRef, + FfiSlice, FfiSliceRef, FfiValueRef, }; use super::{ObjectABI, VTable}; @@ -26,6 +27,10 @@ impl Operation { pub fn deserialize_from>(buffer: &[u8]) -> Result { todo!() } + + pub fn vtable(&self) -> &'static VTable { + self.vtable + } } impl ObjectABI for Operation { @@ -65,7 +70,7 @@ impl OperationVTable { todo!() } - pub fn deserialize_success(&self, buffer: &[u8]) -> Result { + pub fn deserialize_success(&self, buffer: &[u8]) -> Result { todo!() } @@ -73,7 +78,7 @@ impl OperationVTable { todo!() } - pub fn deserialize_failure(&self, buffer: &[u8]) -> Result { + pub fn deserialize_failure(&self, buffer: &[u8]) -> Result { todo!() } } diff --git a/giterated-runtime/giterated-abi/src/vtable/plugin.rs b/giterated-runtime/giterated-abi/src/vtable/plugin.rs index a4ca309..4882686 100644 --- a/giterated-runtime/giterated-abi/src/vtable/plugin.rs +++ b/giterated-runtime/giterated-abi/src/vtable/plugin.rs @@ -1,4 +1,4 @@ -use crate::{value_ex::FfiValueRefUntyped, FfiSliceRef, FfiValueRef}; +use crate::{value_ex::FfiValueRefUntyped, FfiSliceRef}; use super::ObjectABI; diff --git a/giterated-runtime/giterated-abi/src/vtable/runtime.rs b/giterated-runtime/giterated-abi/src/vtable/runtime.rs index 89959f4..40cb196 100644 --- a/giterated-runtime/giterated-abi/src/vtable/runtime.rs +++ b/giterated-runtime/giterated-abi/src/vtable/runtime.rs @@ -1,4 +1,9 @@ -use giterated_models::{error::OperationError, object::ObjectRequestError}; +use giterated_models::{ + error::OperationError, + object::{GiteratedObject, ObjectRequestError}, + object_backend::ObjectBackend, + operation::{GiteratedOperation, OperationState}, +}; use crate::{ result::{FfiError, FfiResult}, @@ -7,14 +12,47 @@ use crate::{ FfiFuture, FfiSliceRef, FfiValueMut, }; +use core::fmt::Debug; + use super::{Object, ObjectABI}; +#[derive(Clone)] pub struct RuntimeHandle; impl ObjectABI for RuntimeHandle { type VTable = RuntimeVTable; } +impl RuntimeHandle { + pub async fn handle_serialized( + &self, + object: &str, + operation_type: &str, + operation_payload: &[u8], + ) -> Result, OperationError>> { + todo!() + } + + pub async fn handle_typed( + &self, + object: O, + operation: D, + ) -> Result> + where + O: GiteratedObject, + D: GiteratedOperation, + { + todo!() + } + + pub async fn inner_get_object( + &self, + object_str: &str, + ) -> Result> { + todo!() + } +} + #[derive(Clone, Copy)] pub struct RuntimeVTable { pub(crate) handle_fn: unsafe extern "C" fn( @@ -50,3 +88,30 @@ pub trait IntoRuntimeVtable { operation_state: FfiValueMut, ) -> FfiResult>; } + +#[async_trait::async_trait(?Send)] +impl ObjectBackend for RuntimeHandle { + async fn object_operation( + &self, + object: O, + operation: &str, + payload: D, + operation_state: &OperationState, + ) -> Result> + where + O: GiteratedObject + Debug + 'static, + D: GiteratedOperation + Debug + 'static, + D::Success: Clone, + D::Failure: Clone, + { + todo!() + } + + async fn get_object( + &self, + object_str: &str, + operation_state: &OperationState, + ) -> Result, OperationError> { + todo!() + } +} diff --git a/giterated-runtime/src/lib.rs b/giterated-runtime/src/lib.rs index 8cfb55f..bfd2fdb 100644 --- a/giterated-runtime/src/lib.rs +++ b/giterated-runtime/src/lib.rs @@ -1,11 +1,7 @@ mod operation_walker; pub mod plugin; -use std::{ - collections::HashMap, - path::{Path, PathBuf}, - sync::Arc, -}; +use std::{collections::HashMap, sync::Arc}; use anyhow::Error; use dlopen2::wrapper::Container; @@ -17,16 +13,12 @@ use giterated_abi::{ CallbackPtr, }, plugin::GiteratedPluginAbi, - vtable::{ - operation::Operation, plugin::Plugin, runtime::RuntimeHandle, Object, Setting, VTable, - Value, - }, + vtable::{operation::Operation, plugin::Plugin, Object, Setting, VTable, Value}, }; use giterated_core::types::TypeMetadata; use giterated_models::{ error::OperationError, object::{GiteratedObject, ObjectOperationPair}, - object_backend::ObjectBackend, operation::GiteratedOperation, settings::ObjectSettingPair, value::ObjectValuePair, @@ -35,7 +27,7 @@ use operation_walker::OperationHandlerRules; use plugin::initialization::PluginInitializationState; use tracing::{debug, debug_span, trace, trace_span, warn}; -pub use giterated_core::RuntimeState; +pub use giterated_abi::vtable::runtime::RuntimeHandle; pub struct Runtime { plugins: Vec, @@ -93,7 +85,7 @@ impl Runtime { pub fn insert_plugin( &mut self, - mut plugin: RuntimePlugin, + plugin: RuntimePlugin, mut initialization: PluginInitializationState, ) { let _guard = debug_span!("inserting plugin", meta = debug(&plugin.name())).entered(); diff --git a/giterated-runtime/src/operation_walker.rs b/giterated-runtime/src/operation_walker.rs index 1b5c150..0e50232 100644 --- a/giterated-runtime/src/operation_walker.rs +++ b/giterated-runtime/src/operation_walker.rs @@ -4,7 +4,7 @@ use giterated_models::{ settings::GetSetting, value::GetValue, }; -use tracing::{debug_span, trace, trace_span}; +use tracing::{trace, trace_span}; use super::{ObjectSettingPair, ObjectValuePair, RuntimeHandlers}; diff --git a/plugins/example-plugin/src/lib.rs b/plugins/example-plugin/src/lib.rs index 8c7d7bc..1f0ac62 100644 --- a/plugins/example-plugin/src/lib.rs +++ b/plugins/example-plugin/src/lib.rs @@ -5,11 +5,7 @@ use giterated_models::{ object::{ObjectRequest, ObjectRequestError, ObjectResponse}, user::{DisplayName, User}, }; -use giterated_plugin::{ - abi::state::{StateExtractor, StateUUID}, - local::PluginStackBuilder, - plugin, -}; +use giterated_plugin::{abi::state::StateUUID, local::PluginStackBuilder, plugin}; plugin!( name: "Example Plugin", diff --git a/plugins/example-plugin/src/main.rs b/plugins/example-plugin/src/main.rs index 029fc0f..f38276f 100644 --- a/plugins/example-plugin/src/main.rs +++ b/plugins/example-plugin/src/main.rs @@ -5,7 +5,6 @@ use giterated_models::{ operation::OperationState, user::{DisplayName, User}, }; -use giterated_plugin::abi::state::RuntimeState; use giterated_plugin::abi::vtable::runtime::RuntimeHandle; use giterated_runtime::{Runtime, StaticRuntimeExt}; use tracing::{info, Level}; diff --git a/plugins/giterated-issues/src/lib.rs b/plugins/giterated-issues/src/lib.rs index b5033d1..f08dbc1 100644 --- a/plugins/giterated-issues/src/lib.rs +++ b/plugins/giterated-issues/src/lib.rs @@ -1,4 +1,4 @@ -use std::{fmt::Display, str::FromStr, sync::OnceLock}; +use std::{fmt::Display, str::FromStr}; use anyhow::Error; use giterated_models::{object::GiteratedObject, repository::Repository}; diff --git a/plugins/giterated-issues/src/main.rs b/plugins/giterated-issues/src/main.rs index 647272c..5b17574 100644 --- a/plugins/giterated-issues/src/main.rs +++ b/plugins/giterated-issues/src/main.rs @@ -28,10 +28,13 @@ pub async fn main() -> Result<(), anyhow::Error> { author: User::from_str("amber:giterated.dev").unwrap(), }; - match runtime.handle_typed( - Repository::from_str("barson:giterated.dev/foo@giterated.dev").unwrap(), - operation, - ) { + match runtime + .handle_typed( + Repository::from_str("barson:giterated.dev/foo@giterated.dev").unwrap(), + operation, + ) + .await + { Ok(success) => { println!("Success in create issue: {:?}", success) } diff --git a/plugins/giterated-protocol/src/handlers.rs b/plugins/giterated-protocol/src/handlers.rs index 59680f6..8ea7227 100644 --- a/plugins/giterated-protocol/src/handlers.rs +++ b/plugins/giterated-protocol/src/handlers.rs @@ -100,7 +100,7 @@ pub async fn try_handle_with_remote( // TODO: // Ideally we support pass-through on object types that aren't used locally. // For now, we aren't worrying about that. - let object_meta = object.vtable(); + // let object_meta = object.vtable(); let operation_meta = operation.vtable(); @@ -110,10 +110,10 @@ pub async fn try_handle_with_remote( // operation.kind().operation_name // ); - let object_home_uri = unsafe { (object_meta.home_uri)(&object) }; + let object_home_uri = object.home_uri(); if let Some(home_uri) = state.home_uri { - if &home_uri == object_home_uri.as_ref() { + if home_uri == object_home_uri { // This isn't a remote request, requests aren't supposed to hit this layer // if they're not remote. // warn!("Try handling object operation {}::{}, resolved object home uri as local home uri. This is a bug.", object.kind(), @@ -133,10 +133,9 @@ pub async fn try_handle_with_remote( let object = todo!(); - let payload = unsafe { (operation_meta.serialize)(&operation) }.unwrap(); - let payload = Vec::from(payload.as_ref()); + let payload = operation.serialize(); - let operation = NetworkedOperation::new(operation_meta.kind().to_string(), payload); + let operation = NetworkedOperation::new(operation.operation_kind().to_string(), payload); // let authenticated = Authenticated::new(object, operation); @@ -162,13 +161,15 @@ pub async fn try_handle_with_remote( match result { Ok(success) => { - let success = unsafe { (operation_meta.deserialize_success)(&success) }.unwrap(); + let success = unsafe { operation_meta.deserialize_success(&success) } + .map_err(|e| e.into_internal())?; Ok(success) } Err(err) => Err(match err { OperationError::Operation(failure) => { - let failure = unsafe { (operation_meta.deserialize_failure)(&failure) }.unwrap(); + let failure = unsafe { operation_meta.deserialize_failure(&failure) } + .map_err(|e| e.into_internal())?; OperationError::Operation(failure) }