pub struct FFIBufManager { /* private fields */ }
Implementations§
Source§impl FFIBufManager
impl FFIBufManager
pub fn alloc(&mut self, len: FFIBufLen) -> FFIBufPtr
Sourcepub unsafe fn dealloc(&mut self, ptr: FFIBufPtr)
pub unsafe fn dealloc(&mut self, ptr: FFIBufPtr)
frees the memory pointed to by ptr
§Safety
The pointer must have been allocated by FFIBufManager::alloc.
pub fn length(&self, ptr: FFIBufPtr) -> FFIBufLen
Sourcepub unsafe fn consume(&mut self, ptr: FFIBufPtr) -> FFIBuf
pub unsafe fn consume(&mut self, ptr: FFIBufPtr) -> FFIBuf
consumes the buffer pointed to by ptr and returns a Vec
§Safety
The pointer must have been allocated by FFIBufManager::alloc.
pub fn encode<T: Serialize>(&mut self, data: &T) -> Result<FFIBufPtr, Error>
Sourcepub unsafe fn decode<T: DeserializeOwned>(
&mut self,
ptr: FFIBufPtr,
) -> Result<T, Error>
pub unsafe fn decode<T: DeserializeOwned>( &mut self, ptr: FFIBufPtr, ) -> Result<T, Error>
decode will consume the raw memory pointed to by ptr and return a deserialized object. After calling decode, manually deallocating the ptr is no longer needed.
§Errors
This function will return an error if deserialization fails. If this happens the memory pointed to by the ptr will also be dropped.
§Safety
The pointer must have been allocated by FFIBufManager::alloc.
Trait Implementations§
Source§impl Default for FFIBufManager
impl Default for FFIBufManager
Source§fn default() -> FFIBufManager
fn default() -> FFIBufManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FFIBufManager
impl RefUnwindSafe for FFIBufManager
impl !Send for FFIBufManager
impl !Sync for FFIBufManager
impl Unpin for FFIBufManager
impl UnwindSafe for FFIBufManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more