use crate::error::VZResult;
use crate::shim_ffi;
use std::ffi::c_void;
pub struct SocketDeviceConfiguration {
inner: *mut c_void,
}
unsafe impl Send for SocketDeviceConfiguration {}
impl SocketDeviceConfiguration {
pub fn new() -> VZResult<Self> {
let obj = unsafe { shim_ffi::abx_socket_device_config_new() };
Ok(Self { inner: obj })
}
#[must_use]
pub(crate) fn into_ptr(self) -> *mut c_void {
let ptr = self.inner;
std::mem::forget(self);
ptr
}
}
impl Default for SocketDeviceConfiguration {
fn default() -> Self {
Self::new().expect("Failed to create socket device configuration")
}
}
impl Drop for SocketDeviceConfiguration {
fn drop(&mut self) {
if !self.inner.is_null() {
unsafe { shim_ffi::abx_object_release(self.inner.cast()) };
}
}
}