use std::ffi::CStr; use crate::{ result::{Error, Result}, value_ex::{FfiValueRefUntyped, FfiValueUntyped}, FfiSlice, FfiSliceRef, FfiValue, FfiValueRef, }; use super::{ObjectABI, VTable}; #[repr(C)] pub struct Operation { inner: FfiValue<()>, vtable: &'static VTable, } impl ObjectABI for Operation { type VTable = OperationVTable; } pub struct OperationVTable { pub operation_kind: &'static CStr, pub operation_serialize: unsafe extern "C" fn(this: FfiValueRef) -> Result, Error>, pub operation_deserialize: unsafe extern "C" fn(buffer: FfiSliceRef<[u8]>) -> Result, pub success_serialize: unsafe extern "C" fn(success: FfiValueRefUntyped) -> Result, Error>, pub success_deserialize: unsafe extern "C" fn(buffer: FfiSliceRef<[u8]>) -> Result, pub failure_serialize: unsafe extern "C" fn(failure: FfiValueRefUntyped) -> Result, Error>, pub failure_deserialize: unsafe extern "C" fn(buffer: FfiSliceRef<[u8]>) -> Result, } impl OperationVTable { pub const fn new() -> Self { todo!() } } pub trait IntoOperationVTable { fn operation_kind() -> &'static CStr; unsafe extern "C" fn operation_serialize( this: FfiValueRef, ) -> Result, Error>; unsafe extern "C" fn operation_deserialize( buffer: FfiSliceRef<[u8]>, ) -> Result; unsafe extern "C" fn success_serialize( success: FfiValueRefUntyped, ) -> Result, Error>; unsafe extern "C" fn success_deserialize( buffer: FfiSliceRef<[u8]>, ) -> Result; unsafe extern "C" fn failure_serialize( failure: FfiValueRefUntyped, ) -> Result, Error>; unsafe extern "C" fn failure_deserialize( buffer: FfiSliceRef<[u8]>, ) -> Result; }