opendaq 0.1.1

Safe Rust bindings for openDAQ, the open-source data acquisition SDK
Documentation
// Generated by tools/generate_bindings.py -- do not edit by hand.

// Mechanical output: lint findings here are the generator's business.
#![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;

/// Provides information about the server.
/// Wrapper over the openDAQ `daqServerType` interface.
#[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 {
    /// Creates a Server type object, with the id, name, description and optional defaultConfig.
    ///
    /// # Parameters
    /// - `id`: The unique type ID of the server.
    /// - `name`: The name of the server type.
    /// - `description`: A short description of the server type.
    /// - `default_config`: The property object, to be cloned and returned, each time user creates default configuration object. This way each instance of the server has its own configuration object.
    ///
    /// Calls the openDAQ C function `daqServerType_createServerType()`.
    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") }?)
    }

}