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