#![allow(clippy::all, unused_imports, rustdoc::bare_urls)]
use crate::error::{check, Error, Result};
use crate::object::{BaseObject, Interface, Ref};
use crate::sys;
use crate::value::{Complex, Ratio, Value};
use crate::generated::*;
use std::ffi::c_char;
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ServerType(pub(crate) ComponentType);
impl std::ops::Deref for ServerType {
type Target = ComponentType;
fn deref(&self) -> &ComponentType { &self.0 }
}
impl crate::sealed::Sealed for ServerType {}
unsafe impl Interface for ServerType {
const NAME: &'static str = "daqServerType";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqServerType_getInterfaceId)(&mut id) };
Some(id)
}
unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
Ref::from_owned(ptr).map(Self::__from_ref)
}
fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl ServerType {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ServerType(ComponentType::__from_ref(r)) }
}
impl std::fmt::Display for ServerType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ServerType> for Value {
fn from(value: &ServerType) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ServerType> for Value {
fn from(value: ServerType) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ServerType {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
impl ServerType {
pub fn new(id: &str, name: &str, description: &str, default_config: &PropertyObject) -> Result<ServerType> {
let __id = crate::marshal::make_string(id)?;
let __name = crate::marshal::make_string(name)?;
let __description = crate::marshal::make_string(description)?;
let mut __obj: *mut sys::daqServerType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqServerType_createServerType)(&mut __obj, __id.as_ptr() as *mut _, __name.as_ptr() as *mut _, __description.as_ptr() as *mut _, default_config.as_raw() as *mut _) };
check(__code, "daqServerType_createServerType")?;
Ok(unsafe { crate::marshal::require_object::<ServerType>(__obj as *mut _, "daqServerType_createServerType") }?)
}
}