use crate::{ result::{FfiError, FfiResult}, value_ex::FfiValueUntyped, FfiSlice, FfiSliceRef, }; use super::{ObjectABI, VTable}; #[repr(C)] pub struct Value { inner: FfiValueUntyped, vtable: &'static VTable, } impl Value { pub fn from(value: T) -> Self { todo!() } } impl ObjectABI for Value { type VTable = ValueVTable; } pub struct ValueVTable { pub serialize: unsafe extern "C" fn(buffer: FfiSliceRef<[u8]>) -> FfiResult, pub deserialize: unsafe extern "C" fn(this: Value) -> FfiResult, FfiError>, } impl ValueVTable { pub const fn new() -> Self { Self { serialize: V::serialize, deserialize: V::deserialize, } } pub fn serialize(&self, value: &Value) -> Result, FfiError> { todo!() } pub fn deserialize(&self, buffer: &[u8]) -> Result { todo!() } } pub trait IntoValueVTable: Sized { const VTABLE: &'static VTable = VTable::new(&ValueVTable::new::()); unsafe extern "C" fn serialize(buffer: FfiSliceRef<[u8]>) -> FfiResult; unsafe extern "C" fn deserialize(this: Value) -> FfiResult, FfiError>; }