// 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 the name and type of a single function/procedure argument
/// Usually part of a list of arguments in a Callable info object.
/// Argument info objects implement the Struct methods internally and are Core type `ctStruct`.
/// Wrapper over the openDAQ `daqArgumentInfo` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ArgumentInfo(pub(crate) BaseObject);
impl std::ops::Deref for ArgumentInfo {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ArgumentInfo {}
unsafe impl Interface for ArgumentInfo {
const NAME: &'static str = "daqArgumentInfo";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqArgumentInfo_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 ArgumentInfo {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ArgumentInfo(BaseObject(r)) }
}
impl std::fmt::Display for ArgumentInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ArgumentInfo> for Value {
fn from(value: &ArgumentInfo) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ArgumentInfo> for Value {
fn from(value: ArgumentInfo) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ArgumentInfo {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// A class which is responsible for authenticating a user. The authentication is usually done by verifying the username and password. An authenticator implementation might use external services for achieving that. It might make a call to an external database, do a lookup to a json file with defined users or it might simply check the password against a hardcoded one.
/// Wrapper over the openDAQ `daqAuthenticationProvider` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct AuthenticationProvider(pub(crate) BaseObject);
impl std::ops::Deref for AuthenticationProvider {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for AuthenticationProvider {}
unsafe impl Interface for AuthenticationProvider {
const NAME: &'static str = "daqAuthenticationProvider";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqAuthenticationProvider_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 AuthenticationProvider {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { AuthenticationProvider(BaseObject(r)) }
}
impl std::fmt::Display for AuthenticationProvider {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&AuthenticationProvider> for Value {
fn from(value: &AuthenticationProvider) -> Value { Value::Object(value.to_base_object()) }
}
impl From<AuthenticationProvider> for Value {
fn from(value: AuthenticationProvider) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for AuthenticationProvider {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Represents boolean variable as `IBoolean` interface. Use this interface to wrap boolean
/// variable when you need to add the variable to lists, dictionaries and other containers which
/// accept `IBaseObject` interface.
/// Available factories:
/// ```text
/// // Creates a new Boolean. Throws exception if not successful.
/// IBoolean* Boolean_Create(Bool value)
/// // Creates a new Boolean. Returns error code if not successful.
/// ErrCode createBoolean(IBoolean** obj, Bool value)
/// ```
/// Wrapper over the openDAQ `daqBoolean` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct BooleanObject(pub(crate) BaseObject);
impl std::ops::Deref for BooleanObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for BooleanObject {}
unsafe impl Interface for BooleanObject {
const NAME: &'static str = "daqBoolean";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqBoolean_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 BooleanObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { BooleanObject(BaseObject(r)) }
}
impl std::fmt::Display for BooleanObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&BooleanObject> for Value {
fn from(value: &BooleanObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<BooleanObject> for Value {
fn from(value: BooleanObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for BooleanObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Provides information about the argument count and types, as well as the return type of Function/Procedure-type properties.
/// A callable should be invoked with the parameter types specified in the `arguments` field, in the
/// order listed.
/// A Procedure-type Property will not have a return type configured in its Callable info field.
/// Argument info objects implement the Struct methods internally and are Core type `ctStruct`.
/// Wrapper over the openDAQ `daqCallableInfo` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct CallableInfo(pub(crate) BaseObject);
impl std::ops::Deref for CallableInfo {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for CallableInfo {}
unsafe impl Interface for CallableInfo {
const NAME: &'static str = "daqCallableInfo";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqCallableInfo_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 CallableInfo {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { CallableInfo(BaseObject(r)) }
}
impl std::fmt::Display for CallableInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&CallableInfo> for Value {
fn from(value: &CallableInfo) -> Value { Value::Object(value.to_base_object()) }
}
impl From<CallableInfo> for Value {
fn from(value: CallableInfo) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for CallableInfo {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Used by openDAQ properties to coerce a value to match the restrictions imposed by the Property.
/// Whenever a value is set to on a Property object, if the corresponding Property has a coercer configured, the value will
/// be evaluated and modified to fit the restrictions imposed by the coercer. For example, a coercer can enforce lower-than,
/// greater-than, equality, or other number relations on written values.
/// The coercion conditions are configured with an evaluation string when the coercer is constructed. The string constructs an
/// Eval value that replaces any instance of the keyword "value" or "val" with the value being set. The result of the Eval
/// value evaluation is the output of the `coerce` function call. For example, coercers created with the string
/// "if(value \> 5, 5, value)" would enforce that the property value is always equal to or lower than 5.
/// Wrapper over the openDAQ `daqCoercer` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Coercer(pub(crate) BaseObject);
impl std::ops::Deref for Coercer {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Coercer {}
unsafe impl Interface for Coercer {
const NAME: &'static str = "daqCoercer";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqCoercer_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 Coercer {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Coercer(BaseObject(r)) }
}
impl std::fmt::Display for Coercer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Coercer> for Value {
fn from(value: &Coercer) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Coercer> for Value {
fn from(value: Coercer) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Coercer {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Arguments object that defines a Core event type, and provides a set of parameters specific to a given event type.
/// Core events are triggered whenever a change in the openDAQ core structure happens. This includes changes to property values,
/// addition/removal of child components, connecting signals to input ports and others. The event type can be identified
/// via the event ID available within the CoreEventArgs object. Each event type has a set of predetermined parameters
/// available in the `parameters` field of the arguments. These can be used by any openDAQ server, or other listener to
/// react to changes within the core structure.
/// Notably, core events trigger only on components that are reachable from the root of the openDAQ tree. Actions such as
/// adding properties during the creation of a function block will not trigger the event - only attaching the function block
/// to the tree will. Subsequent modification of the function block's properties, however, will trigger events, as the
/// function block is then reachable from the root.
/// The Core Event object can be obtained from the Context object created by the Instance that is available to any component
/// within the openDAQ tree structure.
/// @subsection opendaq_core_events_types Core event types
/// This section provides a list of core event types, when they are triggered, as well as their parameter content.
/// @subsubsection opendaq_core_event_types_value_changed Property value changed
/// Event triggered whenever a value of a component's property is changed. It triggers after the PropertyObject's and Property's
/// `onValueWriteEvent`, providing the value of the property after said events are finished processing.
/// The Property value changed core event does not trigger when updating a component via `update`, and when `beginUpdate` has been called.
/// The "owner" parameter is used to determine whether the change was triggered from within a nested object-type property of the
/// sender component.
/// The parameters dictionary contains:
/// - The Property object owner of the property under the key "Owner"
/// - The name of the property as a string under the key "Name"
/// - The new value of the property under the key "Value"
/// - The relative path to the property owner from the sender component under the key "Path".
/// The "Path" parameter is used for object-type properties where it represents the path to the property through child Property objects.
/// Eg. the path to the "MyInt" property of child object-type property named "Child1" on a component would be "Child1". In the case of
/// deeper nesting of object-type properties (if "Child1" had another object-type property named "Child2") the path would be as follows:
/// "Child1.Child2.MyInt".
/// The ID of the event is 0, and the event name is "PropertyValueChanged".
/// @subsubsection opendaq_core_event_types_update_end Property object update end
/// Event triggered whenever a property object finishes updating - at the end of the `update` call, or when `endUpdate` is called.
/// The "owner" parameter is used to determine whether the update end event was triggered from within a nested object-type property of the
/// sender component.
/// The parameters dictionary contains:
/// - The Property object owner of the property under the key "Owner"
/// - The dictionary of updated properties under the key "UpdatedProperties". The dictionary has the string names
/// of properties as key, and base object values as values.
/// - The relative path to the property owner from the sender component under the key "Path".
/// The "Path" parameter is used for object-type properties where it represents the path to the property through child Property objects.
/// Eg. the path to the "MyInt" property of child object-type property named "Child1" on a component would be "Child1". In the case of
/// deeper nesting of object-type properties (if "Child1" had another object-type property named "Child2") the path would be as follows:
/// "Child1.Child2.MyInt".
/// The ID of the event is 10, and the event name is "PropertyObjectUpdateEnd".
/// @subsubsection opendaq_core_event_types_property_added_removed Property added/removed
/// The Property added and Property removed events are triggered whenever a property is added/removed from a component.
/// The "owner" parameter is used to determine whether the addition/removal was triggered from within a nested object-type
/// property of the sender component.
/// The "added" event contains the following parameters:
/// - The Property object owner of the property under the key "Owner"
/// - The added property as a Property object under the key "Property"
/// - The relative path to the property owner from the sender component under the key "Path".
/// The "removed" event contains the following parameters:
/// - The Property object owner of the property under the key "Owner"
/// - The name of the property as a string under the key "Name"
/// - The relative path to the property owner from the sender component under the key "Path".
/// The "Path" parameter is used for object-type properties where it represents the path to the property through child Property objects.
/// Eg. the path to the "MyInt" property of child object-type property named "Child1" on a component would be "Child1". In the case of
/// deeper nesting of object-type properties (if "Child1" had another object-type property named "Child2") the path would be as follows:
/// "Child1.Child2.MyInt".
/// The ID of the Property added event is 20, and the event name is "PropertyAdded".
/// The ID of the Property removed event is 30, and the event name is "PropertyRemoved".
/// @subsubsection opendaq_core_event_types_component_added_removed Component added/removed
/// The Component added/removed events are triggered whenever a new component is attached or detached from
/// the openDAQ component tree. The event is only triggered when the added/removed component can be
/// reached from the root of the tree. Eg. when creating a new function block, no event will be triggered
/// except for when the entire function block subtree is attached to the main tree.
/// The sender of the event is always the parent component of the added/removed child.
/// The "added" event contains the following parameters:
/// - The added component under the key "Component"
/// The "removed" event contains the following parameters:
/// - The local ID of the property as a string under the key "Id"
/// The ID of the Property added event is 40, and the event name is "ComponentAdded".
/// The ID of the Property removed event is 50, and the event name is "ComponentRemoved".
/// @subsubsection opendaq_core_event_types_signal_conn_disc Signal connected/disconnected
/// Triggered whenever a signal is connected to- or disconnected from an input port.
/// The sender of the event is the input port.
/// The "connected" event contains the following parameters:
/// - The connected signal under the key "Signal"
/// The "disconnected" event has no parameters.
/// The ID of the connected event is 60, and the event name is "SignalConnected".
/// The ID of the disconnected event is 70, and the event name is "SignalDisconnected".
/// @subsubsection opendaq_core_event_types_data_desc Data descriptor changed
/// Triggered whenever the data descriptor of a signal changes.
/// The sender of the event is the signal.
/// The event contains the following parameters:
/// - The new data descriptor under the key "DataDescriptor"
/// The ID of the connected event is 80, and the event name is "DataDescriptorChanged".
/// @subsubsection opendaq_core_event_types_component_update_end Component updated end
/// Event triggered whenever a component finishes updating - at the end of the `update` call.
/// The event has no arguments. When called, the component should be checked for changes.
/// The ID of the event is 90, and the event name is "ComponentUpdateEnd".
/// @subsubsection opendaq_core_event_types_component_modified Attribute changed
/// Event triggered when an internal attribute of a component has been changed. Eg. when the "Active" state of the
/// component is modified.
/// The event has no preset parameters, but instead contains dictionary key-value pairs where the key corresponds to
/// the name of the modified attribute, and the value to its new value.
/// The Attribute changed event payload always has a "AttributeName" key entry in the dictionary, containing the
/// name of the changed attribute.
/// The payload then contains another entry using the "AttributeName" value as the key. That entry contains
/// the new value of the attribute.
/// Currently the following attribute names can be present in the Attribute changed event payload:
/// - Signal: "DomainSignal", "RelatedSignals", "Public"
/// - Component: "Active", "Name", "Description", "Visible"
/// For the "Active" attribute, the payload contains additional entries depending on the cause of the change:
/// - "Active": the new effective active state of the component (always present)
/// - "LocalActive": present when the component's own active state was changed directly by the user
/// - "ParentActive": present when the active state changed due to a parent component's active state change
///
/// # Notes
/// The native streaming server sends an RPC notification for the "Active" attribute change only when both "Active" and "LocalActive" are present in the payload (i.e. the change was triggered locally, not propagated from a parent). The ID of the event is 100, and the event name is "AttributeChanged". @subsubsection opendaq_core_event_types_tags_changed Tags changed Triggered when a tag of the sender component was added or removed. The event contains the following parameters: - The list of tags (list of string) under the key "Tags" The ID of the connected event is 110, and the event name is "TagsChanged". @subsubsection opendaq_core_event_types_component_status Component status changed Triggered whenever a component's status changes (excluding device's connection statuses). The sender of the event is the component. The event contains the following parameters: - The new status value encapsulated within an Enumeration object as a value and the status name as a key - The new status message under the key "Message" The ID of the event is 120, and the event name is "StatusChanged". @subsubsection opendaq_core_event_types_type_added Type added/removed Triggered whenever a new "Type" is added to- or removed from the Type manager. Eg. when a new Struct or Enumeration type is created and added. The sender of the above event types is always an empty Component pointer. The "TypeAdded" event contains the following parameters: - The newly added type under the key "Type" The ID of the event is 130, and the event name is "TypeAdded". The "TypeRemoved" event contains the following parameters: - The name of the removed type under the key "TypeName" The ID of the event is 140, and the event name is "TypeRemoved". @subsubsection opendaq_core_event_types_domain_changed Device domain changed Triggered whenever the "Domain" of a device changes. The sender of the above event types is the device of which domain changed. The "DeviceDomainChanged" event contains the following parameters: - The device domain under the key "DeviceDomain" The ID of the event is 150, and the event name is "DeviceDomainChanged". @subsubsection opendaq_core_event_types_device_connection_status Device connection status changed Triggered whenever connection status of a device changes. The sender of the event is the device of which connection status changed. The event contains the following parameters: - The changed status name string under the key "StatusName" - The new status value encapsulated within an Enumeration object under the key "StatusValue". The possible values: "Connected" - connection just established or restored, "Reconnecting" - connection lost, "Unrecoverable" - reconnection is not possible, "Removed" - connection removed (typically when corresponding streaming source is removed) - The connection string associated with connection under the key "ConnectionString" - The integer value specifying the type of particular connection which status changed (0 - Unknown, 1 - Configuration, 2 - Streaming, 3 - ConfigurationAndStreaming) under the key "ProtocolType" - The Streaming object associated with connection under the key "StreamingObject", the parameter is nullptr if connection is of configuration type or the corresponding streaming connection has been removed - The new status message under the key "Message", the parameter is nullptr if the corresponding connection has been removed The ID of the event is 170, and the event name is "ConnectionStatusChanged". @subsection opendaq_core_event_muting Muting core events Components, as previously mentioned, do not trigger core events until they are connected to the root of the openDAQ tree. This is achieved through internal methods that enable/disable the triggers recursively. By default, each component will not trigger any events - the triggers must be manually enabled. The SDK does this whenever a component is added as a child of a parent, if the parent's core triggers are enabled. When done so, the triggers are enabled recursively for the entirety of the subtree. A converse function can be used to instead recursively mute the events.
/// Wrapper over the openDAQ `daqCoreEventArgs` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct CoreEventArgs(pub(crate) EventArgs);
impl std::ops::Deref for CoreEventArgs {
type Target = EventArgs;
fn deref(&self) -> &EventArgs { &self.0 }
}
impl crate::sealed::Sealed for CoreEventArgs {}
unsafe impl Interface for CoreEventArgs {
const NAME: &'static str = "daqCoreEventArgs";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqCoreEventArgs_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 CoreEventArgs {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { CoreEventArgs(EventArgs::__from_ref(r)) }
}
impl std::fmt::Display for CoreEventArgs {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&CoreEventArgs> for Value {
fn from(value: &CoreEventArgs) -> Value { Value::Object(value.to_base_object()) }
}
impl From<CoreEventArgs> for Value {
fn from(value: CoreEventArgs) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for CoreEventArgs {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Represents a collection of key/value pairs.
/// Wrapper over the openDAQ `daqDict` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DictObject(pub(crate) BaseObject);
impl std::ops::Deref for DictObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for DictObject {}
unsafe impl Interface for DictObject {
const NAME: &'static str = "daqDict";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDict_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 DictObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DictObject(BaseObject(r)) }
}
impl std::fmt::Display for DictObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DictObject> for Value {
fn from(value: &DictObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DictObject> for Value {
fn from(value: DictObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DictObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Wrapper over the openDAQ `daqEndUpdateEventArgs` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct EndUpdateEventArgs(pub(crate) EventArgs);
impl std::ops::Deref for EndUpdateEventArgs {
type Target = EventArgs;
fn deref(&self) -> &EventArgs { &self.0 }
}
impl crate::sealed::Sealed for EndUpdateEventArgs {}
unsafe impl Interface for EndUpdateEventArgs {
const NAME: &'static str = "daqEndUpdateEventArgs";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqEndUpdateEventArgs_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 EndUpdateEventArgs {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { EndUpdateEventArgs(EventArgs::__from_ref(r)) }
}
impl std::fmt::Display for EndUpdateEventArgs {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&EndUpdateEventArgs> for Value {
fn from(value: &EndUpdateEventArgs) -> Value { Value::Object(value.to_base_object()) }
}
impl From<EndUpdateEventArgs> for Value {
fn from(value: EndUpdateEventArgs) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for EndUpdateEventArgs {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Enumerations are immutable objects that encapsulate a value within a predefined set of named integral constants. These constants are predefined in an Enumeration type with the same name as the Enumeration.
/// The Enumeration types are stored within a Type Manager. In any given Instance of openDAQ, a single Type Manager should
/// exist that is part of its Context.
/// When creating an Enumeration object, the Type Manager is used to validate the given enumerator value name against the
/// Enumeration type stored within the Manager. If no type with the given Enumeration name is currently stored,
/// construction of the Enumeration object will fail. Similarly, if the provided enumerator value name is not part of
/// the Enumeration type, the construction of the Enumeration object will also fail.
/// Since the Enumerations objects are immutable the value of an existing Enumeration object cannot be modified.
/// However, the Enumeration object encapsulated by a smart pointer of the corresponding type can be replaced
/// with a newly created one. This replacement is accomplished using the assignment operator with the right
/// operand being a constant string literal containing the enumerator value name valid for the Enumeration type
/// of the original Enumeration object.
/// Wrapper over the openDAQ `daqEnumeration` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Enumeration(pub(crate) BaseObject);
impl std::ops::Deref for Enumeration {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Enumeration {}
unsafe impl Interface for Enumeration {
const NAME: &'static str = "daqEnumeration";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqEnumeration_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 Enumeration {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Enumeration(BaseObject(r)) }
}
impl std::fmt::Display for Enumeration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Enumeration> for Value {
fn from(value: &Enumeration) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Enumeration> for Value {
fn from(value: Enumeration) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Enumeration {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Dynamic expression evaluator
/// Provides dynamic evaluation of expressions. Expression is passed as an argument to a
/// factory function. Expression is evaluated at runtime when result value is requested.
/// Wrapper over the openDAQ `daqEvalValue` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct EvalValue(pub(crate) BaseObject);
impl std::ops::Deref for EvalValue {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for EvalValue {}
unsafe impl Interface for EvalValue {
const NAME: &'static str = "daqEvalValue";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqEvalValue_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 EvalValue {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { EvalValue(BaseObject(r)) }
}
impl std::fmt::Display for EvalValue {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&EvalValue> for Value {
fn from(value: &EvalValue) -> Value { Value::Object(value.to_base_object()) }
}
impl From<EvalValue> for Value {
fn from(value: EvalValue) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for EvalValue {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// @ingroup types_events
/// @defgroup types_event Event
/// Wrapper over the openDAQ `daqEvent` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Event(pub(crate) BaseObject);
impl std::ops::Deref for Event {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Event {}
unsafe impl Interface for Event {
const NAME: &'static str = "daqEvent";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqEvent_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 Event {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Event(BaseObject(r)) }
}
impl std::fmt::Display for Event {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Event> for Value {
fn from(value: &Event) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Event> for Value {
fn from(value: Event) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Event {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Wrapper over the openDAQ `daqFloatObject` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct FloatObject(pub(crate) BaseObject);
impl std::ops::Deref for FloatObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for FloatObject {}
unsafe impl Interface for FloatObject {
const NAME: &'static str = "daqFloatObject";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqFloatObject_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 FloatObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { FloatObject(BaseObject(r)) }
}
impl std::fmt::Display for FloatObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&FloatObject> for Value {
fn from(value: &FloatObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<FloatObject> for Value {
fn from(value: FloatObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for FloatObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Wrapper over the openDAQ `daqFunction` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct FunctionObject(pub(crate) BaseObject);
impl std::ops::Deref for FunctionObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for FunctionObject {}
unsafe impl Interface for FunctionObject {
const NAME: &'static str = "daqFunction";
fn interface_id() -> Option<crate::IntfID> { None }
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 FunctionObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { FunctionObject(BaseObject(r)) }
}
impl std::fmt::Display for FunctionObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&FunctionObject> for Value {
fn from(value: &FunctionObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<FunctionObject> for Value {
fn from(value: FunctionObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for FunctionObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Represents int number as `IInteger` interface. Use this interface to wrap integer
/// variable when you need to add the number to lists, dictionaries and other containers which
/// accept `IBaseObject` and derived interfaces.
/// Available factories:
/// ```text
/// // Creates a new Integer. Throws exception if not successful.
/// IInteger* Integer_Create(Int value)
/// // Creates a new IntObject. Returns error code if not successful.
/// ErrCode createInteger(IInteger** obj, Int value)
/// ```
/// Wrapper over the openDAQ `daqInteger` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct IntegerObject(pub(crate) BaseObject);
impl std::ops::Deref for IntegerObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for IntegerObject {}
unsafe impl Interface for IntegerObject {
const NAME: &'static str = "daqInteger";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqInteger_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 IntegerObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { IntegerObject(BaseObject(r)) }
}
impl std::fmt::Display for IntegerObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&IntegerObject> for Value {
fn from(value: &IntegerObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<IntegerObject> for Value {
fn from(value: IntegerObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for IntegerObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Represents a heterogeneous collection of objects that can be individually accessed by index.
/// Wrapper over the openDAQ `daqList` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ListObject(pub(crate) BaseObject);
impl std::ops::Deref for ListObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ListObject {}
unsafe impl Interface for ListObject {
const NAME: &'static str = "daqList";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqList_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 ListObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ListObject(BaseObject(r)) }
}
impl std::fmt::Display for ListObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ListObject> for Value {
fn from(value: &ListObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ListObject> for Value {
fn from(value: ListObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ListObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Interface for lock guard objects.
/// Wrapper over the openDAQ `daqLockGuard` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct LockGuard(pub(crate) BaseObject);
impl std::ops::Deref for LockGuard {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for LockGuard {}
unsafe impl Interface for LockGuard {
const NAME: &'static str = "daqLockGuard";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqLockGuard_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 LockGuard {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { LockGuard(BaseObject(r)) }
}
impl std::fmt::Display for LockGuard {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&LockGuard> for Value {
fn from(value: &LockGuard) -> Value { Value::Object(value.to_base_object()) }
}
impl From<LockGuard> for Value {
fn from(value: LockGuard) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for LockGuard {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Wrapper over the openDAQ `daqMutex` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Mutex(pub(crate) BaseObject);
impl std::ops::Deref for Mutex {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Mutex {}
unsafe impl Interface for Mutex {
const NAME: &'static str = "daqMutex";
fn interface_id() -> Option<crate::IntfID> { None }
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 Mutex {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Mutex(BaseObject(r)) }
}
impl std::fmt::Display for Mutex {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Mutex> for Value {
fn from(value: &Mutex) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Mutex> for Value {
fn from(value: Mutex) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Mutex {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Represents either a float or an int number.
/// Number is used if data type of the number is not strictly defined, i.e.
/// it can accept a float or an int.
/// Wrapper over the openDAQ `daqNumber` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct NumberObject(pub(crate) BaseObject);
impl std::ops::Deref for NumberObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for NumberObject {}
unsafe impl Interface for NumberObject {
const NAME: &'static str = "daqNumber";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqNumber_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 NumberObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { NumberObject(BaseObject(r)) }
}
impl std::fmt::Display for NumberObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&NumberObject> for Value {
fn from(value: &NumberObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<NumberObject> for Value {
fn from(value: NumberObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for NumberObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// An ownable object can have IPropertyObject as the owner.
/// An object can declare itself ownable. When a parent object that supports a concept of ownership
/// calls the` setOwner` method, it becomes the owner of the object. It's up to the object's implementation
/// to decide what actions should it forward to the owner.
/// For example, a property object that is a child of another property object will look up property values
/// in their owner's dictionary if the property is not set locally.
/// Wrapper over the openDAQ `daqOwnable` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Ownable(pub(crate) BaseObject);
impl std::ops::Deref for Ownable {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Ownable {}
unsafe impl Interface for Ownable {
const NAME: &'static str = "daqOwnable";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqOwnable_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 Ownable {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Ownable(BaseObject(r)) }
}
impl std::fmt::Display for Ownable {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Ownable> for Value {
fn from(value: &Ownable) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Ownable> for Value {
fn from(value: Ownable) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Ownable {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// A class which is responsible for managing permissions on an object level. Given a user's group, it is possible to restrict or allow read, write and execute permissions for each object. It is also possible to specify if permissions are inherited from parent object
/// Wrapper over the openDAQ `daqPermissionManager` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PermissionManager(pub(crate) BaseObject);
impl std::ops::Deref for PermissionManager {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PermissionManager {}
unsafe impl Interface for PermissionManager {
const NAME: &'static str = "daqPermissionManager";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPermissionManager_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 PermissionManager {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PermissionManager(BaseObject(r)) }
}
impl std::fmt::Display for PermissionManager {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PermissionManager> for Value {
fn from(value: &PermissionManager) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PermissionManager> for Value {
fn from(value: PermissionManager) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PermissionManager {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Internal PermissionManager interface. It should be used only in openDAQ core implementation files.
/// Wrapper over the openDAQ `daqPermissionManagerInternal` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PermissionManagerInternal(pub(crate) BaseObject);
impl std::ops::Deref for PermissionManagerInternal {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PermissionManagerInternal {}
unsafe impl Interface for PermissionManagerInternal {
const NAME: &'static str = "daqPermissionManagerInternal";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPermissionManagerInternal_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 PermissionManagerInternal {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PermissionManagerInternal(BaseObject(r)) }
}
impl std::fmt::Display for PermissionManagerInternal {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PermissionManagerInternal> for Value {
fn from(value: &PermissionManagerInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PermissionManagerInternal> for Value {
fn from(value: PermissionManagerInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PermissionManagerInternal {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// A class which is responsible for creating a permission mask. This is a collection of Permission values which are allowed or denied for a given group id. Permission mask is defined as a 64-bit integer, where each bit corespond to a specific permission defined by Permission enum.
/// Wrapper over the openDAQ `daqPermissionMaskBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PermissionMaskBuilder(pub(crate) BaseObject);
impl std::ops::Deref for PermissionMaskBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PermissionMaskBuilder {}
unsafe impl Interface for PermissionMaskBuilder {
const NAME: &'static str = "daqPermissionMaskBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPermissionMaskBuilder_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 PermissionMaskBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PermissionMaskBuilder(BaseObject(r)) }
}
impl std::fmt::Display for PermissionMaskBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PermissionMaskBuilder> for Value {
fn from(value: &PermissionMaskBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PermissionMaskBuilder> for Value {
fn from(value: PermissionMaskBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PermissionMaskBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// A class which describes a permission configuration for openDAQ object.A configuration object can be constructed using the permission builder class.
/// Wrapper over the openDAQ `daqPermissions` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Permissions(pub(crate) BaseObject);
impl std::ops::Deref for Permissions {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Permissions {}
unsafe impl Interface for Permissions {
const NAME: &'static str = "daqPermissions";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPermissions_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 Permissions {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Permissions(BaseObject(r)) }
}
impl std::fmt::Display for Permissions {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Permissions> for Value {
fn from(value: &Permissions) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Permissions> for Value {
fn from(value: Permissions) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Permissions {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// A class which is responsible for assigning permissions to a property object. Permisison builder can specify allowed and denied permissions for each group. It can also inherit or overwrite premissions from parent objects.
/// Wrapper over the openDAQ `daqPermissionsBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PermissionsBuilder(pub(crate) BaseObject);
impl std::ops::Deref for PermissionsBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PermissionsBuilder {}
unsafe impl Interface for PermissionsBuilder {
const NAME: &'static str = "daqPermissionsBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPermissionsBuilder_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 PermissionsBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PermissionsBuilder(BaseObject(r)) }
}
impl std::fmt::Display for PermissionsBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PermissionsBuilder> for Value {
fn from(value: &PermissionsBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PermissionsBuilder> for Value {
fn from(value: PermissionsBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PermissionsBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Internal Permissions interface. It should be used only in openDAQ core implementation files.
/// Wrapper over the openDAQ `daqPermissionsInternal` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PermissionsInternal(pub(crate) BaseObject);
impl std::ops::Deref for PermissionsInternal {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PermissionsInternal {}
unsafe impl Interface for PermissionsInternal {
const NAME: &'static str = "daqPermissionsInternal";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPermissionsInternal_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 PermissionsInternal {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PermissionsInternal(BaseObject(r)) }
}
impl std::fmt::Display for PermissionsInternal {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PermissionsInternal> for Value {
fn from(value: &PermissionsInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PermissionsInternal> for Value {
fn from(value: PermissionsInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PermissionsInternal {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Wrapper over the openDAQ `daqProcedure` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Procedure(pub(crate) BaseObject);
impl std::ops::Deref for Procedure {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Procedure {}
unsafe impl Interface for Procedure {
const NAME: &'static str = "daqProcedure";
fn interface_id() -> Option<crate::IntfID> { None }
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 Procedure {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Procedure(BaseObject(r)) }
}
impl std::fmt::Display for Procedure {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Procedure> for Value {
fn from(value: &Procedure) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Procedure> for Value {
fn from(value: Procedure) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Procedure {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Defines a set of metadata that describes the values held by a Property object stored under the key equal to the property's name.
/// A property can be added to a Property object or a Property object class. Once added to either, the
/// Property is frozen and can no longer be changed. Adding a Property to a Property object allows for
/// its corresponding value to be get/set. Similarly, when a Property object is created using a Property
/// object class to which a Property was added, corresponding values can be get/set.
/// When retrieving a Property from a Property object, the returned Property is bound to the Property object.
/// Property metadata fields can reference another Property/Value of the bound Property object. Most Property
/// fields can contain an EvalValue that is evaluated once the corresponding Property field's getter is called.
/// For more information on using EvalValues and binding Properties, see the below section "EvalValue fields and
/// Property binding".
/// Below we define the types of fields available and highlight some special property types, and what fields
/// are expected for a specific type of property.
/// Generally, the mandatory fields of a Property are Name, Value type, and Default value.
/// @subsection objects_property_fields Property metadata fields
/// A Property can define the following fields:
/// - \<b\>Name:\</b\> The name of the property. Within a Property object or Property object class, no two properties
/// can have the same name. A Property value is linked to a Property via its name.
/// - \<b\>Value type:\</b\> The type of the corresponding Property value stored in a Property object. The Default
/// value must also be of the same type.
/// - \<b\>Default value:\</b\> The default value of the Property. If no Property value is set on the Property object,
/// the value getter will return the default value.
/// - \<b\>Description:\</b\> A short string description of the property.
/// - \<b\>Item type:\</b\> If the property is a list or dictionary type, the Item type field specifies the types of
/// values stored in the container.
/// - \<b\>Key type:\</b\> If the property is a dictionary type, the Key type specifies the key type of the dictionary.
/// - \<b\>Unit:\</b\> The Property's unit. Eg. second, meter, volt.
/// - \<b\>Min value:\</b\> The minimum value of the Property's corresponding value. The property must be numeric for
/// this field to be valid.
/// - \<b\>Max value:\</b\> The maximum value of the Property's corresponding value. The property must be numeric for
/// this field to be valid.
/// - \<b\>Suggested values:\</b\> A list of suggested values for the property. The list allows a user to see what
/// values are expected for the Property. Those values, however, are not enforced.
/// Only numerical and string-type properties can have suggested values.
/// - \<b\>Selection values:\</b\> A list or dictionary of selection values. If the Selection values field is configured,
/// the value of the Property must be an integer that is used to index into the
/// list/dictionary of selection values.
/// - \<b\>Referenced property:\</b\> Reference to another property on the Property object. When the Referenced property
/// field is set, all getter/setter methods except for those referencing the `name` and
/// the `Referenced property` fields will be invoked on the referenced property instead.
/// This field is usually an EvalValue object, pointing to a different property depending
/// on the Property object's current state.
/// - \<b\>Is referenced:\</b\> If true, the property is referenced by another. Properties with the `Is referenced` field
/// set to true are visible only through the property referencing them and will not be included
/// in the list of visible properties available on the Property object.
/// - \<b\>Validator:\</b\> Validator object that contains an EvalValue expression that checks whether or not the value is
/// valid. See the "Validation and Coercion" section below. See the Validator documentation for
/// more information.
/// - \<b\>Coercer:\</b\> Coercer object that contains an EvalValue expression that coerces any written Property value to
/// the specified boundaries. See the Coercer documentation for more information.
/// - \<b\>Read-only:\</b\> Property values of Properties with `Read-only` set to true cannot be changed. This can be
/// circumvented by using a protected write available through the `PropertyObjectProtected`
/// interface.
/// - \<b\>Callable info:\</b\> Available only for function- and procedure-type properties. Contains information about the
/// parameter and return types of the function/procedure stored as the Property value.
/// - \<b\>On property value write:\</b\> Event triggered when the corresponding Property value is written to. Contains a
/// reference to the Property object and allows for overriding the written value.
/// - \<b\>On property value read:\</b\> Event triggered when the corresponding Property value is read. Contains a reference
/// to the Property object and allows for overriding the read value.
/// @subsection objects_property_binding EvalValue fields and Property binding
/// Properties that are retrieved from a Property object are bound to that Property object. This allows for a Property
/// metadata field to access other Properties and their corresponding values of the Property object. Most fields of a
/// Property can be configured with an EvalValue. The EvalValue is evaluated when the property field is retrieved, allowing
/// for its evaluated value to change depending on the state of the Property object.
/// In an EvalValue expression, other Property object Properties can be referenced with the "%" symbol, while their
/// Property values can be referenced with "$". For example, setting the Visible field to be:
/// `EvalValue(If($showProp == 1))` results in the property being visible only if the Property value of "showProp"
/// is set to 1.
/// @subsection objects_property_selection Selection properties
/// Selection properties are those that have the Selection values field configured with either a
/// list, or dictionary, and its Value type must be Integer. The values of the list/dictionary
/// match the Item type of the property, while the keys of the dictionary must be integers.
/// (matching the Value type).
/// The Property value of a selection property represents the index or key used to retrieve the
/// Selection value from the list/dictionary. As such, the values written to the corresponding
/// Property value are always integers, but the selected value can be of any type.
/// To obtain the selected value, we get the corresponding Property value, and use it as the
/// index/key to obtain the value from our list/dictionary of selection values. Alternatively,
/// the Property object provides a Selection property getter method that automaticlly performs
/// the above steps.
/// Selection properties must have a default value.
/// @subsection objects_property_function Function/Procedure properties
/// Function properties have the Value type Function or Procedure. Functions are callable methods
/// that have an optional return type, while procedures do not return anything. The property
/// value of a Function/Procedure property is a callable object.
/// To determine the parameter count and types, as well as the return type, the Callable info
/// field must be configured. Callable info contains a list of argument types that need to
/// be passed as arguments when invoking the callable object. If the Property is a Function,
/// the Callable info field also contains the type of the variable returned by the function.
/// Importantly, Function and Procedure type properties are currently not accessible through the
/// OPC UA layer. Thus, they will not appear on connected-to devices.
/// Function and Procedure type properties cannot have a default value.
/// @subsection objects_property_reference Reference properties
/// Reference properties have the Referenced property field configured. The Referenced property
/// contains a pointer to another Property that is part of the same Property object. On such
/// properties, all Property field getters except for the Name, Is referenced, Referenced
/// property, Value type, Key type, and Item type return the metadata fields of the referenced
/// Property. Similarly, the Property object value getters and setters get/set the value of the
/// referenced property.
/// The Referenced property field is configured with an EvalValue that most often switches
/// between different properties depending on the value of another property. For example the
/// `EvalValue` string "switch($switchProp, 0, %prop1, 1, %prop2)" reads the value of the
/// property named "switchProp" and references the property named "prop1" if the value is 0. If
/// the value is 1, it references "prop2" instead.
/// A Property can be referenced by only one Property within a Property object.
/// Reference properties can only have the Name and Referenced property fields configured. Their
/// Value type is always undefined.
/// @subsection objects_property_object_type Object-type properties
/// Object type properties have the Value type Object. These kinds of properties allow for
/// Properties to be grouped and represented in a hierarchy of nested Property objects. A value
/// of an object-type Property can only be a base Property object. Objects such as Devices or
/// Function blocks that are descendants of the Property object class cannot be set as the
/// Property value.
/// Object type properties can only have their Name, Description and Default value configured,
/// where the Default value is mandatory.
/// Object properties, as all other Property types get frozen once added to a Property
/// Object. The notable exception is that locally, the object (default value) is cloned and cached.
/// When the Property value of the Object-type Property is read, the cloned object is returned instead
/// of the default value. This cloned object is not frozen, allowing for the any Properties of
/// the child Property Object to be modified. The same behaviour is applied when a Property Object
/// is created from a Property Object Class - all Object-type properties of the class are cloned.
/// Notably, a object-type property cannot be replaced via `set property value` (unless using
/// `set protected property value`), but calling `clear property value` will call `clear property value`
/// on all of the object's properties. `clear property value` cannot be called of the object-type
/// property is read-only.
/// @subsection objects_property_containers Container-type properties
/// Container type properties have the Value type List or Dictionary and must be homogeneous -
/// they can only have the keys and values of the same type. Their Key and Item types are
/// configured to match that of the Property's Default value. Any new Property value must
/// adhere to the original key and item type.
/// Containers cannot contain Object-type values, Container-type values (List, Dictionary),
/// or Function-type values. Same applies for they Key type of dictionary objects.
/// Importantly, Container-type properties cannot have empty default values as of now. If the
/// default values are empty, the Key and Item type deduction will not work properly,
/// evaluating the types to be undefined.
/// Container properties must have a default value.
/// @subsection objects_property_numbers Numerical properties
/// Numerical properties represent numbers. Their values can be either Integers or Floating
/// point numbers, depending on the configured Value type. Numerical properties can have
/// the Min and Max value fields configured to limit the range of values accepted.
/// Additionally, Numerical properties they can have a list of Suggested values, indicating the
/// expected values for the Property. Note that the Property system does not enforce that a
/// Property value matches a number in the list of Suggested values.
/// Numerical properties must have a default value.
/// @subsection objects_property_structs Struct properties
/// Struct properties represent structures of pre-defined key-value pairs. A Structure property
/// has Value type `ctStruct`. It stores the Structure type of the Struct given as the default value.
/// New Struct values must have the same Struct type as the default.
/// Wrapper over the openDAQ `daqProperty` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Property(pub(crate) BaseObject);
impl std::ops::Deref for Property {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Property {}
unsafe impl Interface for Property {
const NAME: &'static str = "daqProperty";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqProperty_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 Property {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Property(BaseObject(r)) }
}
impl std::fmt::Display for Property {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Property> for Value {
fn from(value: &Property) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Property> for Value {
fn from(value: Property) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Property {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// The builder interface of Properties. Allows for construction of Properties through the `build` method.
/// Contains setters for the Property fields. The setters take as parameters openDAQ objects, even if
/// the value must always evaluate to, for example, a boolean. This allows for EvalValue objects to be
/// set instead of a static value.
/// The EvalValue objects can evaluate to Boolean, String, List, Unit, and Property types. and can thus be
/// used when such types are expected from the getters.
/// The Property can be built by calling the `build` method.
/// Wrapper over the openDAQ `daqPropertyBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyBuilder(pub(crate) BaseObject);
impl std::ops::Deref for PropertyBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PropertyBuilder {}
unsafe impl Interface for PropertyBuilder {
const NAME: &'static str = "daqPropertyBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPropertyBuilder_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 PropertyBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyBuilder(BaseObject(r)) }
}
impl std::fmt::Display for PropertyBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyBuilder> for Value {
fn from(value: &PropertyBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyBuilder> for Value {
fn from(value: PropertyBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// @ingroup objects_property
/// @addtogroup objects_property_obj PropertyInternal
/// Wrapper over the openDAQ `daqPropertyInternal` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyInternal(pub(crate) BaseObject);
impl std::ops::Deref for PropertyInternal {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PropertyInternal {}
unsafe impl Interface for PropertyInternal {
const NAME: &'static str = "daqPropertyInternal";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPropertyInternal_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 PropertyInternal {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyInternal(BaseObject(r)) }
}
impl std::fmt::Display for PropertyInternal {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyInternal> for Value {
fn from(value: &PropertyInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyInternal> for Value {
fn from(value: PropertyInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyInternal {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// A container of Properties and their corresponding Property values.
/// The Property object acts as a container of properties that can be inherited from a specified Property object class,
/// or added to the Property object after its creation. The property names must be unique within any given Property object,
/// as no duplicates are allowed.
/// The Property object class name is specified when constructing the Property object, and the class itself is obtained from
/// the Type manager, which, at that point, must already contain a class with the specified name.
/// Each Property defines a set of metadata, specifying what value type it represents, as well as additional information that
/// is used when displaying a user interface, such as whether a Property is visible, or read-only. The Property can
/// also limit the set of valid values by specifying a minimum/maximum value, or validation/coercion expressions.
/// In addition to properties, a Property object holds a dictionary of Property values, where the key is a Property's name,
/// and the value is the current Property value. When setting the value of a property, the value is written into the said dictionary.
/// Correspondingly, when reading the value of a property, it is read from the dictionary as well. If the value is not present in
/// the dictionary, the default value of the Property is read instead.
/// Property values must match the Value, Item, and Key type of the corresponding Property. If the Property expects an integer type,
/// only objects of which core type is equal to ctInt can be written to said Property. The Item type represents the type of items
/// expected in lists and dictionaries (when the value type is ctList or ctDict), while the Key type represents the type of keys
/// expected in a dictionary (when the value type is ctDict). Notable, when the Property expects object type values, only other
/// base Property objects can be written to said property. Any classes that inherit the Property object class are not valid Property
/// values.
/// Property objects can be frozen. When frozen, their set of Properties and Property values can no longer be modified.
/// Wrapper over the openDAQ `daqPropertyObject` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyObject(pub(crate) BaseObject);
impl std::ops::Deref for PropertyObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PropertyObject {}
unsafe impl Interface for PropertyObject {
const NAME: &'static str = "daqPropertyObject";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPropertyObject_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 PropertyObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyObject(BaseObject(r)) }
}
impl std::fmt::Display for PropertyObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyObject> for Value {
fn from(value: &PropertyObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyObject> for Value {
fn from(value: PropertyObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Container of properties that can be used as a base class when instantiating a Property object.
/// A Property object class is defined via a name and a list of properties. For a Property object to be
/// created, using a class as its base, a class must be added to the Type manager.
/// The name of the class must be unique within a given Type manager instance. The name of the Class
/// is used when choosing a template class for a Property object, as well as to define a class hierarchy.
/// A class with the Parent name configured will inherit the properties of the class with said name.
/// The properties of a Property object class are, by default, sorted in insertion order. The order can,
/// however, be overridden by specifying a Property object order - a list containing the names of properties.
/// If specified, when retrieving the list of properties, they will be in the provided order.
/// All Property object class objects are created as Property object class builder objects that allow for
/// customization and building of the class.
/// Wrapper over the openDAQ `daqPropertyObjectClass` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyObjectClass(pub(crate) Type);
impl std::ops::Deref for PropertyObjectClass {
type Target = Type;
fn deref(&self) -> &Type { &self.0 }
}
impl crate::sealed::Sealed for PropertyObjectClass {}
unsafe impl Interface for PropertyObjectClass {
const NAME: &'static str = "daqPropertyObjectClass";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPropertyObjectClass_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 PropertyObjectClass {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyObjectClass(Type::__from_ref(r)) }
}
impl std::fmt::Display for PropertyObjectClass {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyObjectClass> for Value {
fn from(value: &PropertyObjectClass) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyObjectClass> for Value {
fn from(value: PropertyObjectClass) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyObjectClass {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// The builder interface of Property object classes. Allows for their modification and building of Property object classes.
/// The configuration interface allows for modifying the list of properties, the class's name, parent, and the
/// sorting order of properties. To build the Class, the `build` method is used.
/// Wrapper over the openDAQ `daqPropertyObjectClassBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyObjectClassBuilder(pub(crate) BaseObject);
impl std::ops::Deref for PropertyObjectClassBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PropertyObjectClassBuilder {}
unsafe impl Interface for PropertyObjectClassBuilder {
const NAME: &'static str = "daqPropertyObjectClassBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_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 PropertyObjectClassBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyObjectClassBuilder(BaseObject(r)) }
}
impl std::fmt::Display for PropertyObjectClassBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyObjectClassBuilder> for Value {
fn from(value: &PropertyObjectClassBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyObjectClassBuilder> for Value {
fn from(value: PropertyObjectClassBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyObjectClassBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// @ingroup objects_property_object
/// @addtogroup objects_property_object_class PropertyObjectClassInternal
/// Wrapper over the openDAQ `daqPropertyObjectClassInternal` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyObjectClassInternal(pub(crate) BaseObject);
impl std::ops::Deref for PropertyObjectClassInternal {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PropertyObjectClassInternal {}
unsafe impl Interface for PropertyObjectClassInternal {
const NAME: &'static str = "daqPropertyObjectClassInternal";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPropertyObjectClassInternal_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 PropertyObjectClassInternal {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyObjectClassInternal(BaseObject(r)) }
}
impl std::fmt::Display for PropertyObjectClassInternal {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyObjectClassInternal> for Value {
fn from(value: &PropertyObjectClassInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyObjectClassInternal> for Value {
fn from(value: PropertyObjectClassInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyObjectClassInternal {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// @ingroup objects_property_object
/// @addtogroup objects_property_object_obj PropertyObjectInternal
/// Wrapper over the openDAQ `daqPropertyObjectInternal` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyObjectInternal(pub(crate) BaseObject);
impl std::ops::Deref for PropertyObjectInternal {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PropertyObjectInternal {}
unsafe impl Interface for PropertyObjectInternal {
const NAME: &'static str = "daqPropertyObjectInternal";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPropertyObjectInternal_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 PropertyObjectInternal {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyObjectInternal(BaseObject(r)) }
}
impl std::fmt::Display for PropertyObjectInternal {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyObjectInternal> for Value {
fn from(value: &PropertyObjectInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyObjectInternal> for Value {
fn from(value: PropertyObjectInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyObjectInternal {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Provides protected access that allows changing read-only property values of a Property object.
/// Wrapper over the openDAQ `daqPropertyObjectProtected` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyObjectProtected(pub(crate) BaseObject);
impl std::ops::Deref for PropertyObjectProtected {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PropertyObjectProtected {}
unsafe impl Interface for PropertyObjectProtected {
const NAME: &'static str = "daqPropertyObjectProtected";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPropertyObjectProtected_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 PropertyObjectProtected {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyObjectProtected(BaseObject(r)) }
}
impl std::fmt::Display for PropertyObjectProtected {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyObjectProtected> for Value {
fn from(value: &PropertyObjectProtected) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyObjectProtected> for Value {
fn from(value: PropertyObjectProtected) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyObjectProtected {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Wrapper over the openDAQ `daqPropertyValueEventArgs` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PropertyValueEventArgs(pub(crate) BaseObject);
impl std::ops::Deref for PropertyValueEventArgs {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PropertyValueEventArgs {}
unsafe impl Interface for PropertyValueEventArgs {
const NAME: &'static str = "daqPropertyValueEventArgs";
fn interface_id() -> Option<crate::IntfID> { None }
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 PropertyValueEventArgs {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PropertyValueEventArgs(BaseObject(r)) }
}
impl std::fmt::Display for PropertyValueEventArgs {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PropertyValueEventArgs> for Value {
fn from(value: &PropertyValueEventArgs) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PropertyValueEventArgs> for Value {
fn from(value: PropertyValueEventArgs) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PropertyValueEventArgs {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Represents rational number as `IRatio` interface. Use this interface to wrap
/// rational number when you need to add the number to lists, dictionaries and
/// other containers which accept `IBaseObject` and derived interfaces.
/// Rational numbers are defined as numerator / denominator.
/// Available factories:
/// ```text
/// // Creates a new Ratio object. Throws exception if not successful.
/// IRatio* Ratio_Create(Int numerator, Int denominator)
/// // Creates a new Ratio object. Returns error code if not successful.
/// ErrCode createRatio(IRatio** obj, Int numerator, Int denominator)
/// ```
/// Wrapper over the openDAQ `daqRatio` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct RatioObject(pub(crate) BaseObject);
impl std::ops::Deref for RatioObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for RatioObject {}
unsafe impl Interface for RatioObject {
const NAME: &'static str = "daqRatio";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqRatio_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 RatioObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { RatioObject(BaseObject(r)) }
}
impl std::fmt::Display for RatioObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&RatioObject> for Value {
fn from(value: &RatioObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<RatioObject> for Value {
fn from(value: RatioObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for RatioObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Search filter that can be passed as an optional parameter to search functions to filter out unwanted results. Allows for recursive searches.
/// Each filter defines an "accepts object" and "visit children" function.
/// Accepts object defines whether or not the object being evaluated as part of a search method should be included
/// in the resulting output.
/// Visit children defines whether or not the children of said object should be traversed during a recursive search.
/// Wrapper over the openDAQ `daqSearchFilter` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct SearchFilter(pub(crate) BaseObject);
impl std::ops::Deref for SearchFilter {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for SearchFilter {}
unsafe impl Interface for SearchFilter {
const NAME: &'static str = "daqSearchFilter";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqSearchFilter_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 SearchFilter {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { SearchFilter(BaseObject(r)) }
}
impl std::fmt::Display for SearchFilter {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&SearchFilter> for Value {
fn from(value: &SearchFilter) -> Value { Value::Object(value.to_base_object()) }
}
impl From<SearchFilter> for Value {
fn from(value: SearchFilter) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for SearchFilter {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Represents string variable as `IString` interface. Use this interface to wrap string
/// variable when you need to add the variable to lists, dictionaries and other containers which
/// accept `IBaseObject` and derived interfaces.
/// Available factories:
/// ```text
/// // Creates a new String object. Throws exception if not successful.
/// IString* String_Create(ConstCharPtr value)
/// // Creates a new String object with predefined length. Returns error code if not successful.
/// ErrCode createString(IString** obj, ConstCharPtr value)
/// // Creates a new String object with predefined length. Throws exception if not successful.
/// IString* StringN_Create(ConstCharPtr data, SizeT length)
/// // Creates a new String object. Returns error code if not successful.
/// ErrCode createStringN(IString** obj, ConstCharPtr data, SizeT length)
/// ```
/// Wrapper over the openDAQ `daqString` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct StringObject(pub(crate) BaseObject);
impl std::ops::Deref for StringObject {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for StringObject {}
unsafe impl Interface for StringObject {
const NAME: &'static str = "daqString";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqString_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 StringObject {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { StringObject(BaseObject(r)) }
}
impl std::fmt::Display for StringObject {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&StringObject> for Value {
fn from(value: &StringObject) -> Value { Value::Object(value.to_base_object()) }
}
impl From<StringObject> for Value {
fn from(value: StringObject) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for StringObject {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Structs are immutable objects that contain a set of key-value pairs. The key, as well as the types of each associated value for each struct are defined in advance within a Struct type that has the same name as the Struct.
/// The Struct types are stored within a Type manager. In any given instance of openDAQ, a single Type manager should
/// exist that is part of its Context.
/// When creating a Struct, the Type manager is used to validate the given dictionary of keys and values against the
/// Struct type stored within the manager. If no type with the given Struct name is currently stored, a default type
/// is created using the Struct field names and values as its parameters. When creating a Struct, fields that are part
/// of the Struct type can be omitted. If so, they will be replaced by either `null` or, if provided by the Struct type,
/// the default value of the field.
/// In the case that a field name is present that is not part of the struct type, or if the value type of the field does
/// not match, construction of the Struct will fail.
/// NOTE: Field values of fields with the Core type `ctUndefined` can hold any value, regardless of its type.
/// Structs are an openDAQ core type (ctStruct). Several objects in openDAQ such as an Unit, or DataDescriptor are Structs,
/// allowing for access to their fields through Struct methods. Such objects are, by definiton, immutable - their fields
/// cannot be modified. In order to change the value of a Struct-type object, a new Struct must be created.
/// A Struct can only have fields of Core type: `ctBool`, `ctInt`, `ctFloat`, `ctString`, `ctList`, `ctDict`, `ctRatio`, `ctComplexNumber`,
/// `ctStruct`, or `ctUndefined`. Additionally, all Container types (`ctList`, `ctDict`) should only have values of the aforementioned
/// types.
/// Wrapper over the openDAQ `daqStruct` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Struct(pub(crate) BaseObject);
impl std::ops::Deref for Struct {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Struct {}
unsafe impl Interface for Struct {
const NAME: &'static str = "daqStruct";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqStruct_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 Struct {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Struct(BaseObject(r)) }
}
impl std::fmt::Display for Struct {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Struct> for Value {
fn from(value: &Struct) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Struct> for Value {
fn from(value: Struct) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Struct {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Struct types define the fields (names and value types, as well as optional default values) of Structs with a name matching that of the Struct type.
/// A Struct type contains a String-type name, a list of field names (list of Strings), a list of field types (list of Type objects),
/// and an optional list of Default values (list of Base objects). The Struct types should be added to the Type manager to be used
/// for Struct validation on creation. Alternatively, if a Struct is created with no matching Struct type in the manager, a default
/// Struct type is created based on the field names and types of the Created struct. Said Struct type is then added to the manager.
/// The field types are a list of Type objects. These determine the types of values that should be used to fill in the corresponding
/// field value. The Type objects at the moment available in openDAQ are Simple types and Struct types. When adding any field other
/// than a Struct type, the Simple type corresponding to the Core type of the value should be created. When adding Struct fields, a
/// Struct type should be added to the field types.
/// A Struct can only have fields of Core type: `ctBool`, `ctInt`, `ctFloat`, `ctString`, `ctList`, `ctDict`, `ctRatio`, `ctComplexNumber`,
/// `ctStruct`, or `ctUndefined`. Additionally, all Container types (`ctList`, `ctDict`) should only have values of the aforementioned
/// types.
/// Wrapper over the openDAQ `daqStructType` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct StructType(pub(crate) Type);
impl std::ops::Deref for StructType {
type Target = Type;
fn deref(&self) -> &Type { &self.0 }
}
impl crate::sealed::Sealed for StructType {}
unsafe impl Interface for StructType {
const NAME: &'static str = "daqStructType";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqStructType_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 StructType {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { StructType(Type::__from_ref(r)) }
}
impl std::fmt::Display for StructType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&StructType> for Value {
fn from(value: &StructType) -> Value { Value::Object(value.to_base_object()) }
}
impl From<StructType> for Value {
fn from(value: StructType) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for StructType {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// The base object type that is inherited by all Types (eg. Struct type, Simple type, Property object class) in openDAQ.
/// Types are used for the construction of objects that are require validation/have pre-defined fields such as
/// Structs and Property objects. Types should be inserted into the Type manager to be used by different parts
/// of the SDK.
/// Wrapper over the openDAQ `daqType` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Type(pub(crate) BaseObject);
impl std::ops::Deref for Type {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Type {}
unsafe impl Interface for Type {
const NAME: &'static str = "daqType";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqType_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 Type {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Type(BaseObject(r)) }
}
impl std::fmt::Display for Type {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Type> for Value {
fn from(value: &Type) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Type> for Value {
fn from(value: Type) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Type {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Container for Type objects. The Type manager is used when creating certain types of objects (eg. Structs and Property object classes). The Types stored within the manager contain pre-defined fields, as well as constraints specifying how objects should look.
/// The currently available types in openDAQ that should be added to the Type manager are the Struct type
/// and the Property object class. The former is used to validate Structs when they are created, while the latter
/// contains pre-defined properties that are added to Property objects on construction.
/// When adding a Property object class to the manager, they can form inheritance chains with one-another.
/// Thus, a parent of a given class must be added to the manager before any of its children. Likewise, a class
/// cannot be removed before its children are removed.
/// Wrapper over the openDAQ `daqTypeManager` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct TypeManager(pub(crate) BaseObject);
impl std::ops::Deref for TypeManager {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for TypeManager {}
unsafe impl Interface for TypeManager {
const NAME: &'static str = "daqTypeManager";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqTypeManager_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 TypeManager {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { TypeManager(BaseObject(r)) }
}
impl std::fmt::Display for TypeManager {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&TypeManager> for Value {
fn from(value: &TypeManager) -> Value { Value::Object(value.to_base_object()) }
}
impl From<TypeManager> for Value {
fn from(value: TypeManager) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for TypeManager {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Describes a measurement unit with IDs as defined in \<a href="https://unece.org/trade/cefact/UNLOCODE-Download"\>Codes for Units of Measurement used in International Trade\</a\>.
/// Unit objects implement the Struct methods internally and are Core type `ctStruct`.
/// @subsection unit_components Unit components
/// - ID: The unit ID as defined in \<a href="https://unece.org/trade/cefact/UNLOCODE-Download"\>Codes for Units of Measurement used in International Trade\</a\>.
/// Should be set to -1 if the unit ID is not available.
/// - Symbol: The symbol of the unit, i.e. "m/s". It is mandatory and must be set before the Unit object is frozen.
/// - Name: The full name of the unit, i.e. "meters per second". The unit's name is optional.
/// - Quantity: The quantity represented by the unit, i.e. "Velocity". The unit's quantity is optional.
/// Wrapper over the openDAQ `daqUnit` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Unit(pub(crate) BaseObject);
impl std::ops::Deref for Unit {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Unit {}
unsafe impl Interface for Unit {
const NAME: &'static str = "daqUnit";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqUnit_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 Unit {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Unit(BaseObject(r)) }
}
impl std::fmt::Display for Unit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Unit> for Value {
fn from(value: &Unit) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Unit> for Value {
fn from(value: Unit) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Unit {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Builder component of Unit objects. Contains setter methods to configure the Unit parameters, and a `build` method that builds the Unit object.
/// Wrapper over the openDAQ `daqUnitBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct UnitBuilder(pub(crate) BaseObject);
impl std::ops::Deref for UnitBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for UnitBuilder {}
unsafe impl Interface for UnitBuilder {
const NAME: &'static str = "daqUnitBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqUnitBuilder_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 UnitBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { UnitBuilder(BaseObject(r)) }
}
impl std::fmt::Display for UnitBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&UnitBuilder> for Value {
fn from(value: &UnitBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<UnitBuilder> for Value {
fn from(value: UnitBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for UnitBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// An immutable structure which describes an openDAQ user. It holds username, password as a hash string and a list of groups assigned to the user.
/// Wrapper over the openDAQ `daqUser` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct User(pub(crate) BaseObject);
impl std::ops::Deref for User {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for User {}
unsafe impl Interface for User {
const NAME: &'static str = "daqUser";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqUser_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 User {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { User(BaseObject(r)) }
}
impl std::fmt::Display for User {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&User> for Value {
fn from(value: &User) -> Value { Value::Object(value.to_base_object()) }
}
impl From<User> for Value {
fn from(value: User) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for User {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Internal User interface. It should be used only in openDAQ core implementation files.
/// Wrapper over the openDAQ `daqUserInternal` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct UserInternal(pub(crate) BaseObject);
impl std::ops::Deref for UserInternal {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for UserInternal {}
unsafe impl Interface for UserInternal {
const NAME: &'static str = "daqUserInternal";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqUserInternal_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 UserInternal {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { UserInternal(BaseObject(r)) }
}
impl std::fmt::Display for UserInternal {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&UserInternal> for Value {
fn from(value: &UserInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl From<UserInternal> for Value {
fn from(value: UserInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for UserInternal {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Used by openDAQ properties to validate whether a value fits the value restrictions of the Property.
/// Whenever a value is set to on a Property object, if the corresponding Property has a validator configured, the value will
/// be validated, throwing a validation error, if the value is not compliant with the validation restrictions. For example,
/// a validator can check the written value for lower-than, greater-than, equality, or other number relations.
/// The validation conditions are configured with an evaluation string when the validator is constructed. The string constructs an
/// Eval value that replaces any instance of the keyword "value" or "val" with the value being set. The result of the Eval
/// value evaluation is the output of the `validate` function call. For example, validators created with the string
/// "value == 5" would reject any value that is not equal to 5.
/// Wrapper over the openDAQ `daqValidator` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Validator(pub(crate) BaseObject);
impl std::ops::Deref for Validator {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Validator {}
unsafe impl Interface for Validator {
const NAME: &'static str = "daqValidator";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqValidator_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 Validator {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Validator(BaseObject(r)) }
}
impl std::fmt::Display for Validator {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Validator> for Value {
fn from(value: &Validator) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Validator> for Value {
fn from(value: Validator) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Validator {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
impl ArgumentInfo {
/// Creates an Argument info object with the specified name and type.
///
/// # Parameters
/// - `name`: The name of the argument.
/// - `type`: The type expected of the argument.
///
/// Calls the openDAQ C function `daqArgumentInfo_createArgumentInfo()`.
pub fn new(name: &str, type_: CoreType) -> Result<ArgumentInfo> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqArgumentInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqArgumentInfo_createArgumentInfo)(&mut __obj, __name.as_ptr() as *mut _, type_ as u32) };
check(__code, "daqArgumentInfo_createArgumentInfo")?;
Ok(unsafe { crate::marshal::require_object::<ArgumentInfo>(__obj as *mut _, "daqArgumentInfo_createArgumentInfo") }?)
}
/// Creates a dict-type Argument info object with the specified name, key type and item type.
///
/// # Parameters
/// - `name`: The name of the argument.
/// - `key_type`: Corresponds to the expected type of key in the dictionary argument.
/// - `item_type`: Corresponds to the expected type of items in the dictionary argument.
///
/// Calls the openDAQ C function `daqArgumentInfo_createDictArgumentInfo()`.
pub fn dict(name: &str, key_type: CoreType, item_type: CoreType) -> Result<ArgumentInfo> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqArgumentInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqArgumentInfo_createDictArgumentInfo)(&mut __obj, __name.as_ptr() as *mut _, key_type as u32, item_type as u32) };
check(__code, "daqArgumentInfo_createDictArgumentInfo")?;
Ok(unsafe { crate::marshal::require_object::<ArgumentInfo>(__obj as *mut _, "daqArgumentInfo_createDictArgumentInfo") }?)
}
/// Creates a list-type Argument info object with the specified name and item type.
///
/// # Parameters
/// - `name`: The name of the argument.
/// - `item_type`: Corresponds to the expected type of items in the list argument.
///
/// Calls the openDAQ C function `daqArgumentInfo_createListArgumentInfo()`.
pub fn list(name: &str, item_type: CoreType) -> Result<ArgumentInfo> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqArgumentInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqArgumentInfo_createListArgumentInfo)(&mut __obj, __name.as_ptr() as *mut _, item_type as u32) };
check(__code, "daqArgumentInfo_createListArgumentInfo")?;
Ok(unsafe { crate::marshal::require_object::<ArgumentInfo>(__obj as *mut _, "daqArgumentInfo_createListArgumentInfo") }?)
}
/// Gets the item type of list/dict-type Argument Info objects. The item type specifies the type of values in the list or dictionary arguments.
///
/// # Returns
/// - `item_type`: The item type of the list/dictionary argument. In list-type Argument Info, the type of each item corresponds to the item type. In dict-type Argument Info, the type of each value in the \<key, value\> pairing corresponds to the item type.
///
/// Calls the openDAQ C function `daqArgumentInfo_getItemType()`.
pub fn item_type(&self) -> Result<CoreType> {
let mut __item_type: u32 = 0;
let __code = unsafe { (crate::sys::api().daqArgumentInfo_getItemType)(self.as_raw() as *mut _, &mut __item_type) };
check(__code, "daqArgumentInfo_getItemType")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__item_type), "daqArgumentInfo_getItemType")?)
}
/// Gets the key type of dict-type Argument Info objects. The item type specifies the type of keys in dictionary arguments.
///
/// # Returns
/// - `key_type`: The key type of the dictionary argument.
///
/// Calls the openDAQ C function `daqArgumentInfo_getKeyType()`.
pub fn key_type(&self) -> Result<CoreType> {
let mut __key_type: u32 = 0;
let __code = unsafe { (crate::sys::api().daqArgumentInfo_getKeyType)(self.as_raw() as *mut _, &mut __key_type) };
check(__code, "daqArgumentInfo_getKeyType")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__key_type), "daqArgumentInfo_getKeyType")?)
}
/// Gets the name of the argument.
///
/// # Returns
/// - `name`: The name of the argument.
///
/// Calls the openDAQ C function `daqArgumentInfo_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqArgumentInfo_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqArgumentInfo_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets the core type of the argument.
///
/// # Returns
/// - `type`: The type of the argument. Dictionary, List and Object types should be avoided in public function/procedure callable objects as their key, item, or base interface type cannot be determined without internal knowledge of the function/procedure.
///
/// Calls the openDAQ C function `daqArgumentInfo_getType()`.
pub fn type_(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqArgumentInfo_getType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqArgumentInfo_getType")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqArgumentInfo_getType")?)
}
}
impl AuthenticationProvider {
/// Authenticate user using username and password. If authentication is successful, a User instance is returned. Otherwise an exception is thrown.
///
/// # Parameters
/// - `username`: The username.
/// - `password`: The password in plain text.
/// - `user`: \[out\] And instance of successfully authenticated user. If authentication is not successful, an exception is thrown.
///
/// Calls the openDAQ C function `daqAuthenticationProvider_authenticate()`.
pub fn authenticate(&self, username: &str, password: &str) -> Result<Option<User>> {
let __username = crate::marshal::make_string(username)?;
let __password = crate::marshal::make_string(password)?;
let mut __user_out: *mut sys::daqUser = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqAuthenticationProvider_authenticate)(self.as_raw() as *mut _, __username.as_ptr() as *mut _, __password.as_ptr() as *mut _, &mut __user_out) };
check(__code, "daqAuthenticationProvider_authenticate")?;
Ok(unsafe { crate::marshal::take_object::<User>(__user_out as *mut _) })
}
/// Authenticate as anonymous user. If anonymous authentication is not allowed, an exception is thrown.
///
/// # Parameters
/// - `user`: \[out\] Pointer to anonymous user instance. If authentication is not successful, an exception is thrown.
///
/// Calls the openDAQ C function `daqAuthenticationProvider_authenticateAnonymous()`.
pub fn authenticate_anonymous(&self) -> Result<Option<User>> {
let mut __user_out: *mut sys::daqUser = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqAuthenticationProvider_authenticateAnonymous)(self.as_raw() as *mut _, &mut __user_out) };
check(__code, "daqAuthenticationProvider_authenticateAnonymous")?;
Ok(unsafe { crate::marshal::take_object::<User>(__user_out as *mut _) })
}
/// Creates an empty authentication provider without any user.
///
/// # Parameters
/// - `allow_anonymous`: True if anonymous authentication is allowed.
///
/// Calls the openDAQ C function `daqAuthenticationProvider_createAuthenticationProvider()`.
pub fn new(allow_anonymous: bool) -> Result<AuthenticationProvider> {
let mut __obj: *mut sys::daqAuthenticationProvider = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqAuthenticationProvider_createAuthenticationProvider)(&mut __obj, u8::from(allow_anonymous)) };
check(__code, "daqAuthenticationProvider_createAuthenticationProvider")?;
Ok(unsafe { crate::marshal::require_object::<AuthenticationProvider>(__obj as *mut _, "daqAuthenticationProvider_createAuthenticationProvider") }?)
}
/// Creates an authentication provider out of json file.
///
/// # Parameters
/// - `filename`: File path to a json file containing a list of serialized User objects.
///
/// Calls the openDAQ C function `daqAuthenticationProvider_createJsonFileAuthenticationProvider()`.
pub fn json_file(filename: &str) -> Result<AuthenticationProvider> {
let __filename = crate::marshal::make_string(filename)?;
let mut __obj: *mut sys::daqAuthenticationProvider = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqAuthenticationProvider_createJsonFileAuthenticationProvider)(&mut __obj, __filename.as_ptr() as *mut _) };
check(__code, "daqAuthenticationProvider_createJsonFileAuthenticationProvider")?;
Ok(unsafe { crate::marshal::require_object::<AuthenticationProvider>(__obj as *mut _, "daqAuthenticationProvider_createJsonFileAuthenticationProvider") }?)
}
/// Creates an authentication provider out of json string.
///
/// # Parameters
/// - `json_string`: Json string containg a list of serialized User objects.
///
/// Calls the openDAQ C function `daqAuthenticationProvider_createJsonStringAuthenticationProvider()`.
pub fn json_string(json_string: &str) -> Result<AuthenticationProvider> {
let __json_string = crate::marshal::make_string(json_string)?;
let mut __obj: *mut sys::daqAuthenticationProvider = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqAuthenticationProvider_createJsonStringAuthenticationProvider)(&mut __obj, __json_string.as_ptr() as *mut _) };
check(__code, "daqAuthenticationProvider_createJsonStringAuthenticationProvider")?;
Ok(unsafe { crate::marshal::require_object::<AuthenticationProvider>(__obj as *mut _, "daqAuthenticationProvider_createJsonStringAuthenticationProvider") }?)
}
/// Creates an authentication provider out of static list of users.
///
/// # Parameters
/// - `allow_anonymous`: True if anonymous authentication is allowed.
/// - `user_list`: List of User objects.
///
/// Calls the openDAQ C function `daqAuthenticationProvider_createStaticAuthenticationProvider()`.
pub fn static_(allow_anonymous: bool, user_list: impl Into<Value>) -> Result<AuthenticationProvider> {
let __user_list = crate::value::to_daq(&user_list.into())?;
let mut __obj: *mut sys::daqAuthenticationProvider = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqAuthenticationProvider_createStaticAuthenticationProvider)(&mut __obj, u8::from(allow_anonymous), crate::value::opt_ref_ptr(&__user_list) as *mut _) };
check(__code, "daqAuthenticationProvider_createStaticAuthenticationProvider")?;
Ok(unsafe { crate::marshal::require_object::<AuthenticationProvider>(__obj as *mut _, "daqAuthenticationProvider_createStaticAuthenticationProvider") }?)
}
/// Find a user instance by its username. If no user with maching username is not found, null is returned.
///
/// # Parameters
/// - `username`: The username.
/// - `user_out`: \[out\] Found user instance. If no user with maching username is not found, null is returned.
///
/// Calls the openDAQ C function `daqAuthenticationProvider_findUser()`.
pub fn find_user(&self, username: &str) -> Result<Option<User>> {
let __username = crate::marshal::make_string(username)?;
let mut __user_out: *mut sys::daqUser = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqAuthenticationProvider_findUser)(self.as_raw() as *mut _, __username.as_ptr() as *mut _, &mut __user_out) };
check(__code, "daqAuthenticationProvider_findUser")?;
Ok(unsafe { crate::marshal::take_object::<User>(__user_out as *mut _) })
}
/// Returns true if anonymous authentication is allowed. When anonymous authentication is enabled, user can connect to the server without providing username or password.
///
/// # Parameters
/// - `allowed_out`: \[out\] True if anonymous authentication is allowed.
///
/// Calls the openDAQ C function `daqAuthenticationProvider_isAnonymousAllowed()`.
pub fn is_anonymous_allowed(&self) -> Result<bool> {
let mut __allowed_out: u8 = 0;
let __code = unsafe { (crate::sys::api().daqAuthenticationProvider_isAnonymousAllowed)(self.as_raw() as *mut _, &mut __allowed_out) };
check(__code, "daqAuthenticationProvider_isAnonymousAllowed")?;
Ok(__allowed_out != 0)
}
}
impl BooleanObject {
/// Calls the openDAQ C function `daqBoolean_createBoolObject()`.
pub fn bool_object(value: bool) -> Result<BooleanObject> {
let mut __obj: *mut sys::daqBoolean = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqBoolean_createBoolObject)(&mut __obj, u8::from(value)) };
check(__code, "daqBoolean_createBoolObject")?;
Ok(unsafe { crate::marshal::require_object::<BooleanObject>(__obj as *mut _, "daqBoolean_createBoolObject") }?)
}
/// Compares stored boolean value to the boolean parameter.
///
/// # Parameters
/// - `value`: Value for comparison.
///
/// # Returns
/// - `equal`: The result of the comparison. Call this method to directly compare the object to the boolean parameter.
///
/// Calls the openDAQ C function `daqBoolean_equalsValue()`.
pub fn equals_value(&self, value: bool) -> Result<bool> {
let mut __equal: u8 = 0;
let __code = unsafe { (crate::sys::api().daqBoolean_equalsValue)(self.as_raw() as *mut _, u8::from(value), &mut __equal) };
check(__code, "daqBoolean_equalsValue")?;
Ok(__equal != 0)
}
/// Gets a boolean value stored in the object.
///
/// # Returns
/// OPENDAQ_SUCCESS if succeeded, error code otherwise. Call this method to extract the boolean value that is stored in the object.
/// - `value`: Stored boolean value.
///
/// Calls the openDAQ C function `daqBoolean_getValue()`.
pub fn value(&self) -> Result<bool> {
let mut __value: u8 = 0;
let __code = unsafe { (crate::sys::api().daqBoolean_getValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqBoolean_getValue")?;
Ok(__value != 0)
}
}
impl CallableInfo {
/// Creates a CallableInfo object with the specified arguments and return type.
///
/// # Parameters
/// - `argument_info`: The list of `ArgumentInfo` type argument information.
/// - `return_type`: The return type of the described callable object.
/// - `const_flag`: A flag indicating if the function is marked as const or not. A const function promises not to modify the state of the device or any other objects under the openDAQ instance.
///
/// Calls the openDAQ C function `daqCallableInfo_createCallableInfo()`.
pub fn new(argument_info: impl Into<Value>, return_type: CoreType, const_flag: bool) -> Result<CallableInfo> {
let __argument_info = crate::value::to_daq(&argument_info.into())?;
let mut __obj: *mut sys::daqCallableInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCallableInfo_createCallableInfo)(&mut __obj, crate::value::opt_ref_ptr(&__argument_info) as *mut _, return_type as u32, u8::from(const_flag)) };
check(__code, "daqCallableInfo_createCallableInfo")?;
Ok(unsafe { crate::marshal::require_object::<CallableInfo>(__obj as *mut _, "daqCallableInfo_createCallableInfo") }?)
}
/// Gets the list of arguments the callable function/procedure expects.
///
/// # Returns
/// - `argument_info`: the list of arguments of type `ArgumentInfo`.
///
/// Calls the openDAQ C function `daqCallableInfo_getArguments()`.
pub fn arguments(&self) -> Result<Vec<ArgumentInfo>> {
let mut __argument_info: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCallableInfo_getArguments)(self.as_raw() as *mut _, &mut __argument_info) };
check(__code, "daqCallableInfo_getArguments")?;
Ok(unsafe { crate::marshal::take_list::<ArgumentInfo>(__argument_info as *mut _, "daqCallableInfo_getArguments") }?)
}
/// Gets the return type of the callable function.
///
/// # Returns
/// - `type`: The return type of the callable.
///
/// Calls the openDAQ C function `daqCallableInfo_getReturnType()`.
pub fn return_type(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqCallableInfo_getReturnType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqCallableInfo_getReturnType")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqCallableInfo_getReturnType")?)
}
/// A flag indicating if function is marked as const. A const function promises not to modify the state of the device or any other objects under the openDAQ instance.
///
/// # Returns
/// - `const_flag`: a flag indicating if the function is marked as const or not.
///
/// Calls the openDAQ C function `daqCallableInfo_isConst()`.
pub fn is_const(&self) -> Result<bool> {
let mut __const_flag: u8 = 0;
let __code = unsafe { (crate::sys::api().daqCallableInfo_isConst)(self.as_raw() as *mut _, &mut __const_flag) };
check(__code, "daqCallableInfo_isConst")?;
Ok(__const_flag != 0)
}
}
impl Coercer {
/// Coerces `value` to match the coercion restrictions and outputs the result.
///
/// # Parameters
/// - `prop_obj`: Optional property object parameter required if the coercion depends on other properties of the Property object.
/// - `value`: The value to be coerced to fit the restrictions.
///
/// # Returns
/// - `result`: The coercer output containing the modified `value`.
///
/// # Errors
/// - `OPENDAQ_ERR_COERCE_FAILED`: if `value` cannot be coerced to fit the restrictions.
/// - `OPENDAQ_SUCCESS`: If the value either already fits the restrictions, or was successfully modified to do so.
///
/// Calls the openDAQ C function `daqCoercer_coerce()`.
pub fn coerce(&self, prop_obj: impl Into<Value>, value: impl Into<Value>) -> Result<Value> {
let __prop_obj = crate::value::to_daq(&prop_obj.into())?;
let __value = crate::value::to_daq(&value.into())?;
let mut __result: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoercer_coerce)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__prop_obj) as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _, &mut __result) };
check(__code, "daqCoercer_coerce")?;
Ok(unsafe { crate::value::take_value(__result, "daqCoercer_coerce") }?)
}
/// Calls the openDAQ C function `daqCoercer_coerceNoLock()`.
pub fn coerce_no_lock(&self, prop_obj: impl Into<Value>, value: impl Into<Value>) -> Result<Value> {
let __prop_obj = crate::value::to_daq(&prop_obj.into())?;
let __value = crate::value::to_daq(&value.into())?;
let mut __result: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoercer_coerceNoLock)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__prop_obj) as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _, &mut __result) };
check(__code, "daqCoercer_coerceNoLock")?;
Ok(unsafe { crate::value::take_value(__result, "daqCoercer_coerceNoLock") }?)
}
/// Creates a Coercer with the given evaluation expression.
///
/// # Parameters
/// - `eval`: The evaluation expression used for coercion.
///
/// Calls the openDAQ C function `daqCoercer_createCoercer()`.
pub fn new(eval: &str) -> Result<Coercer> {
let __eval = crate::marshal::make_string(eval)?;
let mut __obj: *mut sys::daqCoercer = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoercer_createCoercer)(&mut __obj, __eval.as_ptr() as *mut _) };
check(__code, "daqCoercer_createCoercer")?;
Ok(unsafe { crate::marshal::require_object::<Coercer>(__obj as *mut _, "daqCoercer_createCoercer") }?)
}
/// Gets the string expression used when creating the coercer.
///
/// # Returns
/// - `eval`: The coercion expression.
///
/// Calls the openDAQ C function `daqCoercer_getEval()`.
pub fn eval(&self) -> Result<String> {
let mut __eval: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoercer_getEval)(self.as_raw() as *mut _, &mut __eval) };
check(__code, "daqCoercer_getEval")?;
Ok(unsafe { crate::marshal::take_string(__eval) })
}
}
impl CoreEventArgs {
/// Creates Core event args with a given ID and custom parameters.
///
/// # Parameters
/// - `event_id`: The ID of the event. If the ID is not equal to one of the pre-defined IDs, the event name will be "Unknown".
/// - `parameters`: The parameters of the event.
///
/// Calls the openDAQ C function `daqCoreEventArgs_createCoreEventArgs()`.
pub fn new(event_id: CoreEventId, event_name: &str, parameters: impl Into<Value>) -> Result<CoreEventArgs> {
let __event_name = crate::marshal::make_string(event_name)?;
let __parameters = crate::value::to_daq(¶meters.into())?;
let mut __obj: *mut sys::daqCoreEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_createCoreEventArgs)(&mut __obj, event_id as u32, __event_name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__parameters) as *mut _) };
check(__code, "daqCoreEventArgs_createCoreEventArgs")?;
Ok(unsafe { crate::marshal::require_object::<CoreEventArgs>(__obj as *mut _, "daqCoreEventArgs_createCoreEventArgs") }?)
}
/// Creates Core event args that are passed as argument when a property is added to a component.
///
/// # Parameters
/// - `prop_owner`: The property object that owns the added property.
/// - `prop`: The property that was added.
/// - `path`: The relative path to the property owner from the sender component. Used for object-type properties. Eg. "child1.child2". Does not include the Component id and property name. The ID of the event is 20, and the event name is "PropertyAdded".
///
/// Calls the openDAQ C function `daqCoreEventArgs_createCoreEventArgsPropertyAdded()`.
pub fn property_added(prop_owner: &PropertyObject, prop: &Property, path: &str) -> Result<CoreEventArgs> {
let __path = crate::marshal::make_string(path)?;
let mut __obj: *mut sys::daqCoreEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_createCoreEventArgsPropertyAdded)(&mut __obj, prop_owner.as_raw() as *mut _, prop.as_raw() as *mut _, __path.as_ptr() as *mut _) };
check(__code, "daqCoreEventArgs_createCoreEventArgsPropertyAdded")?;
Ok(unsafe { crate::marshal::require_object::<CoreEventArgs>(__obj as *mut _, "daqCoreEventArgs_createCoreEventArgsPropertyAdded") }?)
}
/// Creates Core event args that are passed as argument when a property object is finished updating.
///
/// # Parameters
/// - `prop_owner`: The property object that was updated.
/// - `updated_properties`: The dictionary of updated properties. Contains the name (string) of a property as key, and the new value (base object) as the dictionary value.
/// - `path`: The relative path to the property owner from the sender component. Used for object-type properties. Eg. "child1.child2". Does not include the Component id. A property object finished updating when `endUpdate` is called, or at the end of the `update` call. The ID of the event is 10, and the event name is "PropertyObjectUpdateEnd".
///
/// Calls the openDAQ C function `daqCoreEventArgs_createCoreEventArgsPropertyObjectUpdateEnd()`.
pub fn property_object_update_end(prop_owner: &PropertyObject, updated_properties: impl Into<Value>, path: &str) -> Result<CoreEventArgs> {
let __updated_properties = crate::value::to_daq(&updated_properties.into())?;
let __path = crate::marshal::make_string(path)?;
let mut __obj: *mut sys::daqCoreEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_createCoreEventArgsPropertyObjectUpdateEnd)(&mut __obj, prop_owner.as_raw() as *mut _, crate::value::opt_ref_ptr(&__updated_properties) as *mut _, __path.as_ptr() as *mut _) };
check(__code, "daqCoreEventArgs_createCoreEventArgsPropertyObjectUpdateEnd")?;
Ok(unsafe { crate::marshal::require_object::<CoreEventArgs>(__obj as *mut _, "daqCoreEventArgs_createCoreEventArgsPropertyObjectUpdateEnd") }?)
}
/// Creates Core event args that property order of a component is changed.
///
/// # Parameters
/// - `prop_owner`: The property object that owns the properties whose order was changed.
/// - `property_order`: The list of property names in the new order.
/// - `path`: The relative path to the property owner from the sender component. Used for object-type properties. Eg. "child1.child2". The ID of the event is 190, and the event name is "PropertyOrderChanged".
///
/// Calls the openDAQ C function `daqCoreEventArgs_createCoreEventArgsPropertyOrderChanged()`.
pub fn property_order_changed(prop_owner: &PropertyObject, property_order: impl Into<Value>, path: &str) -> Result<CoreEventArgs> {
let __property_order = crate::value::to_daq(&property_order.into())?;
let __path = crate::marshal::make_string(path)?;
let mut __obj: *mut sys::daqCoreEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_createCoreEventArgsPropertyOrderChanged)(&mut __obj, prop_owner.as_raw() as *mut _, crate::value::opt_ref_ptr(&__property_order) as *mut _, __path.as_ptr() as *mut _) };
check(__code, "daqCoreEventArgs_createCoreEventArgsPropertyOrderChanged")?;
Ok(unsafe { crate::marshal::require_object::<CoreEventArgs>(__obj as *mut _, "daqCoreEventArgs_createCoreEventArgsPropertyOrderChanged") }?)
}
/// Creates Core event args that are passed as argument when a property is removed from a component.
///
/// # Parameters
/// - `prop_owner`: The property object that owned the removed property.
/// - `prop_name`: The name of the property that was removed.
/// - `path`: The relative path to the property owner from the sender component. Used for object-type properties. Eg. "child1.child2". Does not include the Component id and property name. The ID of the event is 30, and the event name is "PropertyRemoved".
///
/// Calls the openDAQ C function `daqCoreEventArgs_createCoreEventArgsPropertyRemoved()`.
pub fn property_removed(prop_owner: &PropertyObject, prop_name: &str, path: &str) -> Result<CoreEventArgs> {
let __prop_name = crate::marshal::make_string(prop_name)?;
let __path = crate::marshal::make_string(path)?;
let mut __obj: *mut sys::daqCoreEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_createCoreEventArgsPropertyRemoved)(&mut __obj, prop_owner.as_raw() as *mut _, __prop_name.as_ptr() as *mut _, __path.as_ptr() as *mut _) };
check(__code, "daqCoreEventArgs_createCoreEventArgsPropertyRemoved")?;
Ok(unsafe { crate::marshal::require_object::<CoreEventArgs>(__obj as *mut _, "daqCoreEventArgs_createCoreEventArgsPropertyRemoved") }?)
}
/// Creates Core event args that are passed as argument when a property value of a component is changed.
///
/// # Parameters
/// - `prop_owner`: The property object that owns the changed property.
/// - `prop_name`: The name of the property of which value was changed.
/// - `value`: The new value of the property.
/// - `path`: The relative path to the property owner from the sender component. Used for object-type properties. Eg. "child1.child2". Does not include the Component id and property name. The ID of the event is 0, and the event name is "PropertyValueChanged".
///
/// Calls the openDAQ C function `daqCoreEventArgs_createCoreEventArgsPropertyValueChanged()`.
pub fn property_value_changed(prop_owner: &PropertyObject, prop_name: &str, value: impl Into<Value>, path: &str) -> Result<CoreEventArgs> {
let __prop_name = crate::marshal::make_string(prop_name)?;
let __value = crate::value::to_daq(&value.into())?;
let __path = crate::marshal::make_string(path)?;
let mut __obj: *mut sys::daqCoreEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_createCoreEventArgsPropertyValueChanged)(&mut __obj, prop_owner.as_raw() as *mut _, __prop_name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _, __path.as_ptr() as *mut _) };
check(__code, "daqCoreEventArgs_createCoreEventArgsPropertyValueChanged")?;
Ok(unsafe { crate::marshal::require_object::<CoreEventArgs>(__obj as *mut _, "daqCoreEventArgs_createCoreEventArgsPropertyValueChanged") }?)
}
/// Creates Core event args that are passed as argument when a type is added to the type manager.
///
/// # Parameters
/// - `type`: The type that was added. The ID of the event is 130, and the event name is "TypeAdded".
///
/// Calls the openDAQ C function `daqCoreEventArgs_createCoreEventArgsTypeAdded()`.
pub fn type_added(type_: &Type) -> Result<CoreEventArgs> {
let mut __obj: *mut sys::daqCoreEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_createCoreEventArgsTypeAdded)(&mut __obj, type_.as_raw() as *mut _) };
check(__code, "daqCoreEventArgs_createCoreEventArgsTypeAdded")?;
Ok(unsafe { crate::marshal::require_object::<CoreEventArgs>(__obj as *mut _, "daqCoreEventArgs_createCoreEventArgsTypeAdded") }?)
}
/// Creates Core event args that are passed as argument when a type is removed from the type manager.
///
/// # Parameters
/// - `type_name`: The name of the removed type The ID of the event is 140, and the event name is "TypeRemoved".
///
/// Calls the openDAQ C function `daqCoreEventArgs_createCoreEventArgsTypeRemoved()`.
pub fn type_removed(type_name: &str) -> Result<CoreEventArgs> {
let __type_name = crate::marshal::make_string(type_name)?;
let mut __obj: *mut sys::daqCoreEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_createCoreEventArgsTypeRemoved)(&mut __obj, __type_name.as_ptr() as *mut _) };
check(__code, "daqCoreEventArgs_createCoreEventArgsTypeRemoved")?;
Ok(unsafe { crate::marshal::require_object::<CoreEventArgs>(__obj as *mut _, "daqCoreEventArgs_createCoreEventArgsTypeRemoved") }?)
}
/// Gets the parameters of the core event.
///
/// # Returns
/// - `parameters`: The parameters of the core event.
///
/// Calls the openDAQ C function `daqCoreEventArgs_getParameters()`.
pub fn parameters(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __parameters: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqCoreEventArgs_getParameters)(self.as_raw() as *mut _, &mut __parameters) };
check(__code, "daqCoreEventArgs_getParameters")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__parameters as *mut _, "daqCoreEventArgs_getParameters") }?)
}
}
impl DictObject {
/// Removes all elements from the list.
///
/// Calls the openDAQ C function `daqDict_clear()`.
pub fn clear(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDict_clear)(self.as_raw() as *mut _) };
check(__code, "daqDict_clear")?;
Ok(())
}
/// Calls the openDAQ C function `daqDict_createDict()`.
pub fn new() -> Result<DictObject> {
let mut __obj: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDict_createDict)(&mut __obj) };
check(__code, "daqDict_createDict")?;
Ok(unsafe { crate::marshal::require_object::<DictObject>(__obj as *mut _, "daqDict_createDict") }?)
}
/// Calls the openDAQ C function `daqDict_createDictWithExpectedTypes()`.
pub fn with_expected_types(key_type: crate::IntfID, value_type: crate::IntfID) -> Result<DictObject> {
let mut __obj: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDict_createDictWithExpectedTypes)(&mut __obj, key_type, value_type) };
check(__code, "daqDict_createDictWithExpectedTypes")?;
Ok(unsafe { crate::marshal::require_object::<DictObject>(__obj as *mut _, "daqDict_createDictWithExpectedTypes") }?)
}
/// Deletes the element with the specified key.
///
/// # Parameters
/// - `key`: The key of the element to delete. If the client needs the element deleted, it should use `removeAt` method.
///
/// Calls the openDAQ C function `daqDict_deleteItem()`.
pub fn delete_item(&self, key: impl Into<Value>) -> Result<()> {
let __key = crate::value::to_daq(&key.into())?;
let __code = unsafe { (crate::sys::api().daqDict_deleteItem)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__key) as *mut _) };
check(__code, "daqDict_deleteItem")?;
Ok(())
}
/// Gets the element with the specified key.
///
/// # Parameters
/// - `key`: The key of the element to get.
///
/// # Returns
/// - `value`: The element with the specified key. The reference count of the element that is retrieved is incremented. The client is responsible for calling `releaseRef` when the element is no longer needed.
///
/// Calls the openDAQ C function `daqDict_get()`.
pub fn get(&self, key: impl Into<Value>) -> Result<Value> {
let __key = crate::value::to_daq(&key.into())?;
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDict_get)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__key) as *mut _, &mut __value) };
check(__code, "daqDict_get")?;
Ok(unsafe { crate::value::take_value(__value, "daqDict_get") }?)
}
/// Gets the number of elements contained in the dictionary.
///
/// # Returns
/// - `size`: The number of elements contained in the dictionary.
///
/// Calls the openDAQ C function `daqDict_getCount()`.
pub fn count(&self) -> Result<usize> {
let mut __size: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqDict_getCount)(self.as_raw() as *mut _, &mut __size) };
check(__code, "daqDict_getCount")?;
Ok(__size)
}
/// Gets the list of all keys in the dictionary.
///
/// # Returns
/// - `keys`: The list of the keys. The order of the keys is not defined. The client is responsible for calling `releaseRef` when the list is no longer needed.
///
/// Calls the openDAQ C function `daqDict_getKeyList()`.
pub fn key_list(&self) -> Result<Vec<Value>> {
let mut __keys: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDict_getKeyList)(self.as_raw() as *mut _, &mut __keys) };
check(__code, "daqDict_getKeyList")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__keys as *mut _, "daqDict_getKeyList") }?)
}
/// Gets the iterable interface of the keys.
///
/// # Returns
/// - `iterable`: The iterable interface of the keys. The Iterable interface enables iteration through the keys. The client is responsible for calling `releaseRef` when the interface is no longer needed.
///
/// Calls the openDAQ C function `daqDict_getKeys()`.
pub fn keys(&self) -> Result<Option<Iterable>> {
let mut __iterable: *mut sys::daqIterable = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDict_getKeys)(self.as_raw() as *mut _, &mut __iterable) };
check(__code, "daqDict_getKeys")?;
Ok(unsafe { crate::marshal::take_object::<Iterable>(__iterable as *mut _) })
}
/// Gets the list of all elements in the dictionary.
///
/// # Returns
/// - `values`: The list of the elements. The order of the elements is not defined. The client is responsible for calling `releaseRef` when the list is no longer needed.
///
/// Calls the openDAQ C function `daqDict_getValueList()`.
pub fn value_list(&self) -> Result<Vec<Value>> {
let mut __values: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDict_getValueList)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqDict_getValueList")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__values as *mut _, "daqDict_getValueList") }?)
}
/// Gets the iterable interface of the elements.
///
/// # Returns
/// - `iterable`: The iterable interface of the elements. The Iterable interface enables iteration through the elements. The client is responsible for calling `releaseRef` when the interface is no longer needed.
///
/// Calls the openDAQ C function `daqDict_getValues()`.
pub fn values(&self) -> Result<Option<Iterable>> {
let mut __iterable: *mut sys::daqIterable = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDict_getValues)(self.as_raw() as *mut _, &mut __iterable) };
check(__code, "daqDict_getValues")?;
Ok(unsafe { crate::marshal::take_object::<Iterable>(__iterable as *mut _) })
}
/// Checks if the element with the specified key exists in the dictionary.
///
/// # Parameters
/// - `key`: The key of the element to check.
///
/// # Returns
/// - `has_key`: True if the element exists, False otherwise.
///
/// Calls the openDAQ C function `daqDict_hasKey()`.
pub fn has_key(&self, key: impl Into<Value>) -> Result<bool> {
let __key = crate::value::to_daq(&key.into())?;
let mut __has_key: u8 = 0;
let __code = unsafe { (crate::sys::api().daqDict_hasKey)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__key) as *mut _, &mut __has_key) };
check(__code, "daqDict_hasKey")?;
Ok(__has_key != 0)
}
/// Removes the element with the specified key.
///
/// # Parameters
/// - `key`: The key of the element to remove.
///
/// # Returns
/// - `value`: The element with the specified key. The client is responsible for calling `releaseRef` when the element is no longer needed. If the client does not need the element after it is removed, it should call `delete` method.
///
/// Calls the openDAQ C function `daqDict_remove()`.
pub fn remove(&self, key: impl Into<Value>) -> Result<Value> {
let __key = crate::value::to_daq(&key.into())?;
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDict_remove)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__key) as *mut _, &mut __value) };
check(__code, "daqDict_remove")?;
Ok(unsafe { crate::value::take_value(__value, "daqDict_remove") }?)
}
/// Sets the element with the specified key.
///
/// # Parameters
/// - `key`: The key of the element to set.
/// - `value`: The element with the specified key. The reference count of the key and the element is incremented.
///
/// Calls the openDAQ C function `daqDict_set()`.
pub fn set(&self, key: impl Into<Value>, value: impl Into<Value>) -> Result<()> {
let __key = crate::value::to_daq(&key.into())?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqDict_set)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__key) as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqDict_set")?;
Ok(())
}
}
impl EndUpdateEventArgs {
/// Calls the openDAQ C function `daqEndUpdateEventArgs_createEndUpdateEventArgs()`.
pub fn new(properties: impl Into<Value>, is_parent_updating: bool) -> Result<EndUpdateEventArgs> {
let __properties = crate::value::to_daq(&properties.into())?;
let mut __obj: *mut sys::daqEndUpdateEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEndUpdateEventArgs_createEndUpdateEventArgs)(&mut __obj, crate::value::opt_ref_ptr(&__properties) as *mut _, u8::from(is_parent_updating)) };
check(__code, "daqEndUpdateEventArgs_createEndUpdateEventArgs")?;
Ok(unsafe { crate::marshal::require_object::<EndUpdateEventArgs>(__obj as *mut _, "daqEndUpdateEventArgs_createEndUpdateEventArgs") }?)
}
/// Calls the openDAQ C function `daqEndUpdateEventArgs_getIsParentUpdating()`.
pub fn is_parent_updating(&self) -> Result<bool> {
let mut __is_parent_updating: u8 = 0;
let __code = unsafe { (crate::sys::api().daqEndUpdateEventArgs_getIsParentUpdating)(self.as_raw() as *mut _, &mut __is_parent_updating) };
check(__code, "daqEndUpdateEventArgs_getIsParentUpdating")?;
Ok(__is_parent_updating != 0)
}
/// Calls the openDAQ C function `daqEndUpdateEventArgs_getProperties()`.
pub fn properties(&self) -> Result<Vec<String>> {
let mut __properties: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEndUpdateEventArgs_getProperties)(self.as_raw() as *mut _, &mut __properties) };
check(__code, "daqEndUpdateEventArgs_getProperties")?;
Ok(unsafe { crate::marshal::take_list::<String>(__properties as *mut _, "daqEndUpdateEventArgs_getProperties") }?)
}
}
impl Enumeration {
/// Calls the openDAQ C function `daqEnumeration_createEnumeration()`.
pub fn new(name: &str, value: &str, type_manager: &TypeManager) -> Result<Enumeration> {
let __name = crate::marshal::make_string(name)?;
let __value = crate::marshal::make_string(value)?;
let mut __obj: *mut sys::daqEnumeration = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEnumeration_createEnumeration)(&mut __obj, __name.as_ptr() as *mut _, __value.as_ptr() as *mut _, type_manager.as_raw() as *mut _) };
check(__code, "daqEnumeration_createEnumeration")?;
Ok(unsafe { crate::marshal::require_object::<Enumeration>(__obj as *mut _, "daqEnumeration_createEnumeration") }?)
}
/// Calls the openDAQ C function `daqEnumeration_createEnumerationWithIntValue()`.
pub fn with_int_value(name: &str, value: i64, type_manager: &TypeManager) -> Result<Enumeration> {
let __name = crate::marshal::make_string(name)?;
let __value = crate::value::int_to_ref(value)?;
let mut __obj: *mut sys::daqEnumeration = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEnumeration_createEnumerationWithIntValue)(&mut __obj, __name.as_ptr() as *mut _, __value.as_ptr() as *mut _, type_manager.as_raw() as *mut _) };
check(__code, "daqEnumeration_createEnumerationWithIntValue")?;
Ok(unsafe { crate::marshal::require_object::<Enumeration>(__obj as *mut _, "daqEnumeration_createEnumerationWithIntValue") }?)
}
/// Calls the openDAQ C function `daqEnumeration_createEnumerationWithIntValueAndType()`.
pub fn with_int_value_and_type(type_: &EnumerationType, value: i64) -> Result<Enumeration> {
let __value = crate::value::int_to_ref(value)?;
let mut __obj: *mut sys::daqEnumeration = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEnumeration_createEnumerationWithIntValueAndType)(&mut __obj, type_.as_raw() as *mut _, __value.as_ptr() as *mut _) };
check(__code, "daqEnumeration_createEnumerationWithIntValueAndType")?;
Ok(unsafe { crate::marshal::require_object::<Enumeration>(__obj as *mut _, "daqEnumeration_createEnumerationWithIntValueAndType") }?)
}
/// Calls the openDAQ C function `daqEnumeration_createEnumerationWithType()`.
pub fn with_type(type_: &EnumerationType, value: &str) -> Result<Enumeration> {
let __value = crate::marshal::make_string(value)?;
let mut __obj: *mut sys::daqEnumeration = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEnumeration_createEnumerationWithType)(&mut __obj, type_.as_raw() as *mut _, __value.as_ptr() as *mut _) };
check(__code, "daqEnumeration_createEnumerationWithType")?;
Ok(unsafe { crate::marshal::require_object::<Enumeration>(__obj as *mut _, "daqEnumeration_createEnumerationWithType") }?)
}
/// Gets the Enumeration's type.
///
/// # Returns
/// - `type`: The Enumeration type
///
/// Calls the openDAQ C function `daqEnumeration_getEnumerationType()`.
pub fn enumeration_type(&self) -> Result<Option<EnumerationType>> {
let mut __type_: *mut sys::daqEnumerationType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEnumeration_getEnumerationType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqEnumeration_getEnumerationType")?;
Ok(unsafe { crate::marshal::take_object::<EnumerationType>(__type_ as *mut _) })
}
/// Gets the Enumeration value as Integer enumerator constant.
///
/// # Returns
/// - `value`: Emumeration Integer value.
///
/// Calls the openDAQ C function `daqEnumeration_getIntValue()`.
pub fn int_value(&self) -> Result<i64> {
let mut __value: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqEnumeration_getIntValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqEnumeration_getIntValue")?;
Ok(__value)
}
/// Gets the Enumeration value as String containing the name of the enumerator constant.
///
/// # Returns
/// - `value`: Emumeration value.
///
/// Calls the openDAQ C function `daqEnumeration_getValue()`.
pub fn value(&self) -> Result<String> {
let mut __value: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEnumeration_getValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqEnumeration_getValue")?;
Ok(unsafe { crate::marshal::take_string(__value) })
}
}
impl EvalValue {
/// Clones the object and attaches an owner.
///
/// # Parameters
/// - `owner`: The owner to attach to the cloned eval value.
///
/// # Returns
/// - `cloned_value`: The cloned object. When the expression contains reference to some property object, then the expression cannot be evaluated unless an owner is attached to eval value. However, the object can be cloned with the specified owner attached. The client can then evaluate the cloned object.
///
/// Calls the openDAQ C function `daqEvalValue_cloneWithOwner()`.
pub fn clone_with_owner(&self, owner: &PropertyObject) -> Result<Option<EvalValue>> {
let mut __cloned_value: *mut sys::daqEvalValue = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvalValue_cloneWithOwner)(self.as_raw() as *mut _, owner.as_raw() as *mut _, &mut __cloned_value) };
check(__code, "daqEvalValue_cloneWithOwner")?;
Ok(unsafe { crate::marshal::take_object::<EvalValue>(__cloned_value as *mut _) })
}
/// Calls the openDAQ C function `daqEvalValue_createEvalValue()`.
pub fn new(eval: &str) -> Result<EvalValue> {
let __eval = crate::marshal::make_string(eval)?;
let mut __obj: *mut sys::daqEvalValue = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvalValue_createEvalValue)(&mut __obj, __eval.as_ptr() as *mut _) };
check(__code, "daqEvalValue_createEvalValue")?;
Ok(unsafe { crate::marshal::require_object::<EvalValue>(__obj as *mut _, "daqEvalValue_createEvalValue") }?)
}
/// Calls the openDAQ C function `daqEvalValue_createEvalValueArgs()`.
pub fn args(eval: &str, args: impl Into<Value>) -> Result<EvalValue> {
let __eval = crate::marshal::make_string(eval)?;
let __args = crate::value::to_daq(&args.into())?;
let mut __obj: *mut sys::daqEvalValue = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvalValue_createEvalValueArgs)(&mut __obj, __eval.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__args) as *mut _) };
check(__code, "daqEvalValue_createEvalValueArgs")?;
Ok(unsafe { crate::marshal::require_object::<EvalValue>(__obj as *mut _, "daqEvalValue_createEvalValueArgs") }?)
}
/// Calls the openDAQ C function `daqEvalValue_createEvalValueFunc()`.
pub fn func(eval: &str, func: &FunctionObject) -> Result<EvalValue> {
let __eval = crate::marshal::make_string(eval)?;
let mut __obj: *mut sys::daqEvalValue = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvalValue_createEvalValueFunc)(&mut __obj, __eval.as_ptr() as *mut _, func.as_raw() as *mut _) };
check(__code, "daqEvalValue_createEvalValueFunc")?;
Ok(unsafe { crate::marshal::require_object::<EvalValue>(__obj as *mut _, "daqEvalValue_createEvalValueFunc") }?)
}
/// Gets the expression.
///
/// # Returns
/// - `eval`: The expression. Expression is passed as a parameter to the factory function.
///
/// Calls the openDAQ C function `daqEvalValue_getEval()`.
pub fn eval(&self) -> Result<String> {
let mut __eval: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvalValue_getEval)(self.as_raw() as *mut _, &mut __eval) };
check(__code, "daqEvalValue_getEval")?;
Ok(unsafe { crate::marshal::take_string(__eval) })
}
/// Returns the parse error code.
/// When an eval value object is created, the expression is passed as an argument to the factory
/// function. Parsing of the expression can fail, but the factory function will always succeed. Use this
/// function to check if the parsing of the expression succeeded without evaluating the expression.
///
/// Calls the openDAQ C function `daqEvalValue_getParseErrorCode()`.
pub fn parse_error_code(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqEvalValue_getParseErrorCode)(self.as_raw() as *mut _) };
check(__code, "daqEvalValue_getParseErrorCode")?;
Ok(())
}
/// Returns the names of all properties referenced by the eval value.
///
/// # Returns
/// - `property_references`: The names of referenced properties. Referenced properties are all occurrences matching the '"%" propref' pattern in the evaluation string.
///
/// Calls the openDAQ C function `daqEvalValue_getPropertyReferences()`.
pub fn property_references(&self) -> Result<Vec<String>> {
let mut __property_references: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvalValue_getPropertyReferences)(self.as_raw() as *mut _, &mut __property_references) };
check(__code, "daqEvalValue_getPropertyReferences")?;
Ok(unsafe { crate::marshal::take_list::<String>(__property_references as *mut _, "daqEvalValue_getPropertyReferences") }?)
}
/// Gets the result of the expression.
///
/// # Returns
/// - `obj`: The result of the expression.
///
/// # Errors
/// - `OPENDAQ_ERR_CALCFAILED`: when calculation failed.
/// - `OPENDAQ_ERR_RESOLVEFAILED`: when reference resolution failed
/// - `OPENDAQ_ERR_PARSEFAILED`: when expression parsing failed When this method is called for the first time, the object will trigger execution and return result.
///
/// Calls the openDAQ C function `daqEvalValue_getResult()`.
pub fn result(&self) -> Result<Value> {
let mut __obj: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvalValue_getResult)(self.as_raw() as *mut _, &mut __obj) };
check(__code, "daqEvalValue_getResult")?;
Ok(unsafe { crate::value::take_value(__obj, "daqEvalValue_getResult") }?)
}
/// Calls the openDAQ C function `daqEvalValue_getResultNoLock()`.
pub fn result_no_lock(&self) -> Result<Value> {
let mut __obj: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvalValue_getResultNoLock)(self.as_raw() as *mut _, &mut __obj) };
check(__code, "daqEvalValue_getResultNoLock")?;
Ok(unsafe { crate::value::take_value(__obj, "daqEvalValue_getResultNoLock") }?)
}
}
impl Event {
/// Calls the openDAQ C function `daqEvent_addHandler()`.
pub fn add_handler(&self, event_handler: &EventHandler) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqEvent_addHandler)(self.as_raw() as *mut _, event_handler.as_raw() as *mut _) };
check(__code, "daqEvent_addHandler")?;
Ok(())
}
/// Calls the openDAQ C function `daqEvent_clear()`.
pub fn clear(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqEvent_clear)(self.as_raw() as *mut _) };
check(__code, "daqEvent_clear")?;
Ok(())
}
/// Calls the openDAQ C function `daqEvent_createEvent()`.
pub fn new() -> Result<Event> {
let mut __obj: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvent_createEvent)(&mut __obj) };
check(__code, "daqEvent_createEvent")?;
Ok(unsafe { crate::marshal::require_object::<Event>(__obj as *mut _, "daqEvent_createEvent") }?)
}
/// Calls the openDAQ C function `daqEvent_getSubscriberCount()`.
pub fn subscriber_count(&self) -> Result<usize> {
let mut __count: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqEvent_getSubscriberCount)(self.as_raw() as *mut _, &mut __count) };
check(__code, "daqEvent_getSubscriberCount")?;
Ok(__count)
}
/// Calls the openDAQ C function `daqEvent_getSubscribers()`.
pub fn subscribers(&self) -> Result<Vec<Value>> {
let mut __subscribers: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqEvent_getSubscribers)(self.as_raw() as *mut _, &mut __subscribers) };
check(__code, "daqEvent_getSubscribers")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__subscribers as *mut _, "daqEvent_getSubscribers") }?)
}
/// Calls the openDAQ C function `daqEvent_mute()`.
pub fn mute(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqEvent_mute)(self.as_raw() as *mut _) };
check(__code, "daqEvent_mute")?;
Ok(())
}
/// Calls the openDAQ C function `daqEvent_muteListener()`.
pub fn mute_listener(&self, event_handler: &EventHandler) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqEvent_muteListener)(self.as_raw() as *mut _, event_handler.as_raw() as *mut _) };
check(__code, "daqEvent_muteListener")?;
Ok(())
}
/// Calls the openDAQ C function `daqEvent_removeHandler()`.
pub fn remove_handler(&self, event_handler: &EventHandler) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqEvent_removeHandler)(self.as_raw() as *mut _, event_handler.as_raw() as *mut _) };
check(__code, "daqEvent_removeHandler")?;
Ok(())
}
/// Calls the openDAQ C function `daqEvent_trigger()`.
pub fn trigger(&self, sender: impl Into<Value>, args: &EventArgs) -> Result<()> {
let __sender = crate::value::to_daq(&sender.into())?;
let __code = unsafe { (crate::sys::api().daqEvent_trigger)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__sender) as *mut _, args.as_raw() as *mut _) };
check(__code, "daqEvent_trigger")?;
Ok(())
}
/// Calls the openDAQ C function `daqEvent_unmute()`.
pub fn unmute(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqEvent_unmute)(self.as_raw() as *mut _) };
check(__code, "daqEvent_unmute")?;
Ok(())
}
/// Calls the openDAQ C function `daqEvent_unmuteListener()`.
pub fn unmute_listener(&self, event_handler: &EventHandler) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqEvent_unmuteListener)(self.as_raw() as *mut _, event_handler.as_raw() as *mut _) };
check(__code, "daqEvent_unmuteListener")?;
Ok(())
}
}
impl FloatObject {
/// Calls the openDAQ C function `daqFloatObject_createFloatObject()`.
pub fn new(value: f64) -> Result<FloatObject> {
let mut __obj: *mut sys::daqFloatObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqFloatObject_createFloatObject)(&mut __obj, value) };
check(__code, "daqFloatObject_createFloatObject")?;
Ok(unsafe { crate::marshal::require_object::<FloatObject>(__obj as *mut _, "daqFloatObject_createFloatObject") }?)
}
/// Calls the openDAQ C function `daqFloatObject_equalsValue()`.
pub fn equals_value(&self, value: f64) -> Result<bool> {
let mut __equals: u8 = 0;
let __code = unsafe { (crate::sys::api().daqFloatObject_equalsValue)(self.as_raw() as *mut _, value, &mut __equals) };
check(__code, "daqFloatObject_equalsValue")?;
Ok(__equals != 0)
}
/// Calls the openDAQ C function `daqFloatObject_getValue()`.
pub fn value(&self) -> Result<f64> {
let mut __value: f64 = Default::default();
let __code = unsafe { (crate::sys::api().daqFloatObject_getValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqFloatObject_getValue")?;
Ok(__value)
}
}
impl IntegerObject {
/// Calls the openDAQ C function `daqInteger_createInteger()`.
pub fn new(value: i64) -> Result<IntegerObject> {
let mut __obj: *mut sys::daqInteger = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInteger_createInteger)(&mut __obj, value) };
check(__code, "daqInteger_createInteger")?;
Ok(unsafe { crate::marshal::require_object::<IntegerObject>(__obj as *mut _, "daqInteger_createInteger") }?)
}
/// Compares stored int value to the int parameter.
///
/// # Parameters
/// - `value`: Value for comparison.
///
/// # Returns
/// - `equals`: The result of the comparison. Call this method to directly compare the object to the value parameter.
///
/// Calls the openDAQ C function `daqInteger_equalsValue()`.
pub fn equals_value(&self, value: i64) -> Result<bool> {
let mut __equals: u8 = 0;
let __code = unsafe { (crate::sys::api().daqInteger_equalsValue)(self.as_raw() as *mut _, value, &mut __equals) };
check(__code, "daqInteger_equalsValue")?;
Ok(__equals != 0)
}
/// Gets an int value stored in the object.
///
/// # Returns
/// - `value`: Stored int value. Call this method to extract the int value that is stored in the object.
///
/// Calls the openDAQ C function `daqInteger_getValue()`.
pub fn value(&self) -> Result<i64> {
let mut __value: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqInteger_getValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqInteger_getValue")?;
Ok(__value)
}
}
impl ListObject {
/// Removes all elements from the list.
///
/// Calls the openDAQ C function `daqList_clear()`.
pub fn clear(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqList_clear)(self.as_raw() as *mut _) };
check(__code, "daqList_clear")?;
Ok(())
}
/// Creates and returns the stop iterator of the list.
///
/// # Returns
/// - `iterator`: The stop iterator. Use iterators to iterate through the elements.
///
/// Calls the openDAQ C function `daqList_createEndIterator()`.
pub fn create_end_iterator(&self) -> Result<Option<ObjectIterator>> {
let mut __iterator: *mut sys::daqIterator = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqList_createEndIterator)(self.as_raw() as *mut _, &mut __iterator) };
check(__code, "daqList_createEndIterator")?;
Ok(unsafe { crate::marshal::take_object::<ObjectIterator>(__iterator as *mut _) })
}
/// Calls the openDAQ C function `daqList_createList()`.
pub fn new() -> Result<ListObject> {
let mut __obj: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqList_createList)(&mut __obj) };
check(__code, "daqList_createList")?;
Ok(unsafe { crate::marshal::require_object::<ListObject>(__obj as *mut _, "daqList_createList") }?)
}
/// Calls the openDAQ C function `daqList_createListWithElementType()`.
pub fn with_element_type(id: crate::IntfID) -> Result<ListObject> {
let mut __obj: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqList_createListWithElementType)(&mut __obj, id) };
check(__code, "daqList_createListWithElementType")?;
Ok(unsafe { crate::marshal::require_object::<ListObject>(__obj as *mut _, "daqList_createListWithElementType") }?)
}
/// Creates and returns the start iterator of the list.
///
/// # Returns
/// - `iterator`: The start iterator. Use iterators to iterate through the elements.
///
/// Calls the openDAQ C function `daqList_createStartIterator()`.
pub fn create_start_iterator(&self) -> Result<Option<ObjectIterator>> {
let mut __iterator: *mut sys::daqIterator = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqList_createStartIterator)(self.as_raw() as *mut _, &mut __iterator) };
check(__code, "daqList_createStartIterator")?;
Ok(unsafe { crate::marshal::take_object::<ObjectIterator>(__iterator as *mut _) })
}
/// Deletes the element at a specific position.
///
/// # Parameters
/// - `index`: The zero-based index of the element to remove. If the client needs the element deleted, it should use `removeAt` method.
///
/// Calls the openDAQ C function `daqList_deleteAt()`.
pub fn delete_at(&self, index: usize) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqList_deleteAt)(self.as_raw() as *mut _, index) };
check(__code, "daqList_deleteAt")?;
Ok(())
}
/// Gets the number of elements contained in the list.
///
/// # Returns
/// - `size`: The number of elements contained in the list.
///
/// Calls the openDAQ C function `daqList_getCount()`.
pub fn count(&self) -> Result<usize> {
let mut __size: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqList_getCount)(self.as_raw() as *mut _, &mut __size) };
check(__code, "daqList_getCount")?;
Ok(__size)
}
/// Gets the element at a specific position.
///
/// # Parameters
/// - `index`: The zero-based index of the element to get.
///
/// # Returns
/// - `obj`: The element at the specified index. The reference count of the element that is retrieved is incremented. The client is responsible for calling `releaseRef` when the element is no longer needed.
///
/// Calls the openDAQ C function `daqList_getItemAt()`.
pub fn item_at(&self, index: usize) -> Result<Value> {
let mut __obj: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqList_getItemAt)(self.as_raw() as *mut _, index, &mut __obj) };
check(__code, "daqList_getItemAt")?;
Ok(unsafe { crate::value::take_value(__obj, "daqList_getItemAt") }?)
}
/// Inserts the element at a specific position.
///
/// # Parameters
/// - `index`: The zero-based index of the element to insert.
/// - `obj`: The element to insert at the specified index. The reference count of the element is incremented.
///
/// Calls the openDAQ C function `daqList_insertAt()`.
pub fn insert_at(&self, index: usize, obj: impl Into<Value>) -> Result<()> {
let __obj = crate::value::to_daq(&obj.into())?;
let __code = unsafe { (crate::sys::api().daqList_insertAt)(self.as_raw() as *mut _, index, crate::value::opt_ref_ptr(&__obj) as *mut _) };
check(__code, "daqList_insertAt")?;
Ok(())
}
/// Inserts the element at the end of the list without incrementing the reference count.
///
/// # Parameters
/// - `obj`: The element to insert. The reference count of the element is not incremented. The client can use this method when it no longer needs to access the element after calling the method.
///
/// Calls the openDAQ C function `daqList_moveBack()`.
pub fn move_back(&self, obj: impl Into<Value>) -> Result<()> {
let __obj = crate::value::to_daq(&obj.into())?;
let __code = unsafe { (crate::sys::api().daqList_moveBack)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__obj) as *mut _) };
check(__code, "daqList_moveBack")?;
Ok(())
}
/// Inserts the element at the start of the list without incrementing the reference count.
///
/// # Parameters
/// - `obj`: The element to insert. The reference count of the element is not incremented. The client can use this method when it no longer needs to access the element after calling the method.
///
/// Calls the openDAQ C function `daqList_moveFront()`.
pub fn move_front(&self, obj: impl Into<Value>) -> Result<()> {
let __obj = crate::value::to_daq(&obj.into())?;
let __code = unsafe { (crate::sys::api().daqList_moveFront)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__obj) as *mut _) };
check(__code, "daqList_moveFront")?;
Ok(())
}
/// Gets the element from the end of the list.
///
/// # Returns
/// - `obj`: The extracted element. The reference count of the element that is retrieved is incremented. The client is responsible for calling `releaseRef` when the element is no longer needed.
///
/// Calls the openDAQ C function `daqList_popBack()`.
pub fn pop_back(&self) -> Result<Value> {
let mut __obj: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqList_popBack)(self.as_raw() as *mut _, &mut __obj) };
check(__code, "daqList_popBack")?;
Ok(unsafe { crate::value::take_value(__obj, "daqList_popBack") }?)
}
/// Gets the element from the start of the list.
///
/// # Returns
/// - `obj`: The extracted element. The reference count of the element that is retrieved is incremented. The client is responsible for calling `releaseRef` when the element is no longer needed.
///
/// Calls the openDAQ C function `daqList_popFront()`.
pub fn pop_front(&self) -> Result<Value> {
let mut __obj: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqList_popFront)(self.as_raw() as *mut _, &mut __obj) };
check(__code, "daqList_popFront")?;
Ok(unsafe { crate::value::take_value(__obj, "daqList_popFront") }?)
}
/// Inserts the element at the end of the list.
///
/// # Parameters
/// - `obj`: The element to insert. The reference count of the element is incremented.
///
/// Calls the openDAQ C function `daqList_pushBack()`.
pub fn push_back(&self, obj: impl Into<Value>) -> Result<()> {
let __obj = crate::value::to_daq(&obj.into())?;
let __code = unsafe { (crate::sys::api().daqList_pushBack)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__obj) as *mut _) };
check(__code, "daqList_pushBack")?;
Ok(())
}
/// Inserts the element at the start of the list.
///
/// # Parameters
/// - `obj`: The element to insert. The reference count of the element is incremented.
///
/// Calls the openDAQ C function `daqList_pushFront()`.
pub fn push_front(&self, obj: impl Into<Value>) -> Result<()> {
let __obj = crate::value::to_daq(&obj.into())?;
let __code = unsafe { (crate::sys::api().daqList_pushFront)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__obj) as *mut _) };
check(__code, "daqList_pushFront")?;
Ok(())
}
/// Removes the element at a specific position.
///
/// # Parameters
/// - `index`: The zero-based index of the element to remove.
///
/// # Returns
/// - `obj`: The removed element. The client is responsible for calling `releaseRef` when the element is no longer needed. If the client does not need the element after it is removed, it should call `delete` method.
///
/// Calls the openDAQ C function `daqList_removeAt()`.
pub fn remove_at(&self, index: usize) -> Result<Value> {
let mut __obj: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqList_removeAt)(self.as_raw() as *mut _, index, &mut __obj) };
check(__code, "daqList_removeAt")?;
Ok(unsafe { crate::value::take_value(__obj, "daqList_removeAt") }?)
}
/// Sets the element at a specific position.
///
/// # Parameters
/// - `index`: The zero-based index of the element to set.
/// - `obj`: The element to set at the specified index. The reference count of the element is incremented.
///
/// Calls the openDAQ C function `daqList_setItemAt()`.
pub fn set_item_at(&self, index: usize, obj: impl Into<Value>) -> Result<()> {
let __obj = crate::value::to_daq(&obj.into())?;
let __code = unsafe { (crate::sys::api().daqList_setItemAt)(self.as_raw() as *mut _, index, crate::value::opt_ref_ptr(&__obj) as *mut _) };
check(__code, "daqList_setItemAt")?;
Ok(())
}
}
impl NumberObject {
/// Gets a value stored in the object as a floating point value.
///
/// # Returns
/// OPENDAQ_SUCCESS if succeeded, error code otherwise.
/// - `value`: Stored value as a floating point.
///
/// Calls the openDAQ C function `daqNumber_getFloatValue()`.
pub fn float_value(&self) -> Result<f64> {
let mut __value: f64 = Default::default();
let __code = unsafe { (crate::sys::api().daqNumber_getFloatValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqNumber_getFloatValue")?;
Ok(__value)
}
/// Gets a value stored in the object as an integer value.
///
/// # Returns
/// OPENDAQ_SUCCESS if succeeded, error code otherwise.
/// - `value`: Stored value as an integer.
///
/// Calls the openDAQ C function `daqNumber_getIntValue()`.
pub fn int_value(&self) -> Result<i64> {
let mut __value: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqNumber_getIntValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqNumber_getIntValue")?;
Ok(__value)
}
}
impl Ownable {
/// Sets the owner of the object.
///
/// # Parameters
/// - `owner`: The object that will own this object.
///
/// Calls the openDAQ C function `daqOwnable_setOwner()`.
pub fn set_owner(&self, owner: &PropertyObject) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqOwnable_setOwner)(self.as_raw() as *mut _, owner.as_raw() as *mut _) };
check(__code, "daqOwnable_setOwner")?;
Ok(())
}
}
impl PermissionManagerInternal {
/// Adds a reference to the permission manager of a child object.
///
/// # Parameters
/// - `child_manager`: A reference to the permission manager of a child object.
///
/// Calls the openDAQ C function `daqPermissionManagerInternal_addChildManager()`.
pub fn add_child_manager(&self, child_manager: &PermissionManager) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionManagerInternal_addChildManager)(self.as_raw() as *mut _, child_manager.as_raw() as *mut _) };
check(__code, "daqPermissionManagerInternal_addChildManager")?;
Ok(())
}
/// Returns permisisons configuration object.
///
/// # Parameters
/// - `permissions_out`: \[out\] A Permissions configuration object.
///
/// Calls the openDAQ C function `daqPermissionManagerInternal_getPermissions()`.
pub fn permissions(&self) -> Result<Option<Permissions>> {
let mut __permissions_out: *mut sys::daqPermissions = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissionManagerInternal_getPermissions)(self.as_raw() as *mut _, &mut __permissions_out) };
check(__code, "daqPermissionManagerInternal_getPermissions")?;
Ok(unsafe { crate::marshal::take_object::<Permissions>(__permissions_out as *mut _) })
}
/// Removes a reference to the permission manager of a child object.
///
/// # Parameters
/// - `child_manager`: A reference to the permission manager of a child object.
///
/// Calls the openDAQ C function `daqPermissionManagerInternal_removeChildManager()`.
pub fn remove_child_manager(&self, child_manager: &PermissionManager) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionManagerInternal_removeChildManager)(self.as_raw() as *mut _, child_manager.as_raw() as *mut _) };
check(__code, "daqPermissionManagerInternal_removeChildManager")?;
Ok(())
}
/// Change the parant of a permission manager.
///
/// # Parameters
/// - `parent_manager`: A reference to the permission manager of a parent object.
///
/// Calls the openDAQ C function `daqPermissionManagerInternal_setParent()`.
pub fn set_parent(&self, parent_manager: &PermissionManager) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionManagerInternal_setParent)(self.as_raw() as *mut _, parent_manager.as_raw() as *mut _) };
check(__code, "daqPermissionManagerInternal_setParent")?;
Ok(())
}
/// Recursively update permissions of objects with new permissions from their parents.
///
/// Calls the openDAQ C function `daqPermissionManagerInternal_updateInheritedPermissions()`.
pub fn update_inherited_permissions(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionManagerInternal_updateInheritedPermissions)(self.as_raw() as *mut _) };
check(__code, "daqPermissionManagerInternal_updateInheritedPermissions")?;
Ok(())
}
}
impl PermissionManager {
/// Creates an permission manager with a given parent.
///
/// # Parameters
/// - `parent`: Permission manager of a parent object. It can be null for a root object.
///
/// Calls the openDAQ C function `daqPermissionManager_createPermissionManager()`.
pub fn new(parent: &PermissionManager) -> Result<PermissionManager> {
let mut __obj: *mut sys::daqPermissionManager = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissionManager_createPermissionManager)(&mut __obj, parent.as_raw() as *mut _) };
check(__code, "daqPermissionManager_createPermissionManager")?;
Ok(unsafe { crate::marshal::require_object::<PermissionManager>(__obj as *mut _, "daqPermissionManager_createPermissionManager") }?)
}
/// Check if user has a given permission on an object of the permission manager.
///
/// # Parameters
/// - `user`: A reference to the user.
/// - `permission`: A permission to test.
///
/// # Returns
/// - `authorized_out`: Returns true if user is authorized and false otherwise.
///
/// Calls the openDAQ C function `daqPermissionManager_isAuthorized()`.
pub fn is_authorized(&self, user: &User, permission: Permission) -> Result<bool> {
let mut __authorized_out: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPermissionManager_isAuthorized)(self.as_raw() as *mut _, user.as_raw() as *mut _, permission as u32, &mut __authorized_out) };
check(__code, "daqPermissionManager_isAuthorized")?;
Ok(__authorized_out != 0)
}
/// Set object permission configuration.
///
/// # Parameters
/// - `permissions`: Permissions configuration object.
///
/// Calls the openDAQ C function `daqPermissionManager_setPermissions()`.
pub fn set_permissions(&self, permissions: &Permissions) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionManager_setPermissions)(self.as_raw() as *mut _, permissions.as_raw() as *mut _) };
check(__code, "daqPermissionManager_setPermissions")?;
Ok(())
}
}
impl PermissionMaskBuilder {
/// Build permission mask and return it as 64-bit integer.
///
/// # Parameters
/// - `permission_mask`: \[out\] Permission mask defined as 64-bit integer where each bit corresponds to a specific permissoin defined by Permission enum.
///
/// Calls the openDAQ C function `daqPermissionMaskBuilder_build()`.
pub fn build(&self) -> Result<i64> {
let mut __permission_mask: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqPermissionMaskBuilder_build)(self.as_raw() as *mut _, &mut __permission_mask) };
check(__code, "daqPermissionMaskBuilder_build")?;
Ok(__permission_mask)
}
/// Removes all permissions from bit mask.
///
/// Calls the openDAQ C function `daqPermissionMaskBuilder_clear()`.
pub fn clear(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionMaskBuilder_clear)(self.as_raw() as *mut _) };
check(__code, "daqPermissionMaskBuilder_clear")?;
Ok(())
}
/// Creates a permision mask builder object.
///
/// Calls the openDAQ C function `daqPermissionMaskBuilder_createPermissionMaskBuilder()`.
pub fn new() -> Result<PermissionMaskBuilder> {
let mut __obj: *mut sys::daqPermissionMaskBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissionMaskBuilder_createPermissionMaskBuilder)(&mut __obj) };
check(__code, "daqPermissionMaskBuilder_createPermissionMaskBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PermissionMaskBuilder>(__obj as *mut _, "daqPermissionMaskBuilder_createPermissionMaskBuilder") }?)
}
/// Creates a permission mask builder object from integer permission mask.
///
/// # Parameters
/// - `permission_mask`: Permission mask defined as 64-bit integer where each bit corresponds to a specific permission defined in Permission enum.
///
/// Calls the openDAQ C function `daqPermissionMaskBuilder_createPermissionMaskBuilderFromMask()`.
pub fn from_mask(permission_mask: i64) -> Result<PermissionMaskBuilder> {
let mut __obj: *mut sys::daqPermissionMaskBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissionMaskBuilder_createPermissionMaskBuilderFromMask)(&mut __obj, permission_mask) };
check(__code, "daqPermissionMaskBuilder_createPermissionMaskBuilderFromMask")?;
Ok(unsafe { crate::marshal::require_object::<PermissionMaskBuilder>(__obj as *mut _, "daqPermissionMaskBuilder_createPermissionMaskBuilderFromMask") }?)
}
/// Add execute permission to the bit mask.
///
/// Calls the openDAQ C function `daqPermissionMaskBuilder_execute()`.
pub fn execute(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionMaskBuilder_execute)(self.as_raw() as *mut _) };
check(__code, "daqPermissionMaskBuilder_execute")?;
Ok(())
}
/// Add read permission to the bit mask.
///
/// Calls the openDAQ C function `daqPermissionMaskBuilder_read()`.
pub fn read(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionMaskBuilder_read)(self.as_raw() as *mut _) };
check(__code, "daqPermissionMaskBuilder_read")?;
Ok(())
}
/// Add write permission to the bit mask.
///
/// Calls the openDAQ C function `daqPermissionMaskBuilder_write()`.
pub fn write(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionMaskBuilder_write)(self.as_raw() as *mut _) };
check(__code, "daqPermissionMaskBuilder_write")?;
Ok(())
}
}
impl PermissionsBuilder {
/// Allow a specified set of permissions for a given group. If the inherit flag is enabled, this method will allow both the specified permissions and any permissions already allowed for the group on the parent component. Denied permissions will always overrule allowed permissions.
///
/// # Parameters
/// - `group_id`: The id of a group to allow permissions for.
/// - `permissions`: A set of permissions to allow for given group.
///
/// Calls the openDAQ C function `daqPermissionsBuilder_allow()`.
pub fn allow(&self, group_id: &str, permissions: &PermissionMaskBuilder) -> Result<()> {
let __group_id = crate::marshal::make_string(group_id)?;
let __code = unsafe { (crate::sys::api().daqPermissionsBuilder_allow)(self.as_raw() as *mut _, __group_id.as_ptr() as *mut _, permissions.as_raw() as *mut _) };
check(__code, "daqPermissionsBuilder_allow")?;
Ok(())
}
/// Strictly assign a specified set of permissions for a given group. This method allows only the specified permissions and will not inherit any permissions from the parent object for the group, even if the inherit flag is enabled.
///
/// # Parameters
/// - `group_id`: The id of a group to set permissions for.
/// - `permissions`: A set of permissions to allow for given group.
///
/// Calls the openDAQ C function `daqPermissionsBuilder_assign()`.
pub fn assign(&self, group_id: &str, permissions: &PermissionMaskBuilder) -> Result<()> {
let __group_id = crate::marshal::make_string(group_id)?;
let __code = unsafe { (crate::sys::api().daqPermissionsBuilder_assign)(self.as_raw() as *mut _, __group_id.as_ptr() as *mut _, permissions.as_raw() as *mut _) };
check(__code, "daqPermissionsBuilder_assign")?;
Ok(())
}
/// Builds the permission config object.
///
/// # Parameters
/// - `config_out`: \[out\] Permission config object.
///
/// Calls the openDAQ C function `daqPermissionsBuilder_build()`.
pub fn build(&self) -> Result<Option<Permissions>> {
let mut __config_out: *mut sys::daqPermissions = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissionsBuilder_build)(self.as_raw() as *mut _, &mut __config_out) };
check(__code, "daqPermissionsBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<Permissions>(__config_out as *mut _) })
}
/// Creates a Permissions builder object.
///
/// Calls the openDAQ C function `daqPermissionsBuilder_createPermissionsBuilder()`.
pub fn new() -> Result<PermissionsBuilder> {
let mut __obj: *mut sys::daqPermissionsBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissionsBuilder_createPermissionsBuilder)(&mut __obj) };
check(__code, "daqPermissionsBuilder_createPermissionsBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PermissionsBuilder>(__obj as *mut _, "daqPermissionsBuilder_createPermissionsBuilder") }?)
}
/// Deny a specified set of permissions for a given group. If the inherit flag is enabled, this method will deny both the specified permissions and any permissions already denied for the group on the parent component. Denied permissions will always overrule allowed permissions.
///
/// # Parameters
/// - `group_id`: The id of a group to deny permissions for.
/// - `permissions`: A set of permissions to deny for given group.
///
/// Calls the openDAQ C function `daqPermissionsBuilder_deny()`.
pub fn deny(&self, group_id: &str, permissions: &PermissionMaskBuilder) -> Result<()> {
let __group_id = crate::marshal::make_string(group_id)?;
let __code = unsafe { (crate::sys::api().daqPermissionsBuilder_deny)(self.as_raw() as *mut _, __group_id.as_ptr() as *mut _, permissions.as_raw() as *mut _) };
check(__code, "daqPermissionsBuilder_deny")?;
Ok(())
}
/// Add permissions of another permission config object and overwrite existing ones. Inherit flag will not be overwritten.
///
/// # Parameters
/// - `config`: Permission config object.
///
/// Calls the openDAQ C function `daqPermissionsBuilder_extend()`.
pub fn extend(&self, config: &Permissions) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionsBuilder_extend)(self.as_raw() as *mut _, config.as_raw() as *mut _) };
check(__code, "daqPermissionsBuilder_extend")?;
Ok(())
}
/// Configure component to inherit or ignore permissions from the parent object.
///
/// # Parameters
/// - `inherit`: Flag signifying if component should inherit permissions from its parent object.
///
/// Calls the openDAQ C function `daqPermissionsBuilder_inherit()`.
pub fn inherit(&self, inherit: bool) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPermissionsBuilder_inherit)(self.as_raw() as *mut _, u8::from(inherit)) };
check(__code, "daqPermissionsBuilder_inherit")?;
Ok(())
}
}
impl PermissionsInternal {
/// Returns a dictionary of assigned permissions for each group.
///
/// # Parameters
/// - `permissions`: \[out\] A dictionary of assigned permissions for each group.
///
/// Calls the openDAQ C function `daqPermissionsInternal_getAssigned()`.
pub fn assigned(&self) -> Result<std::collections::HashMap<String, i64>> {
let mut __permissions: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissionsInternal_getAssigned)(self.as_raw() as *mut _, &mut __permissions) };
check(__code, "daqPermissionsInternal_getAssigned")?;
Ok(unsafe { crate::marshal::take_dict::<String, i64>(__permissions as *mut _, "daqPermissionsInternal_getAssigned") }?)
}
}
impl Permissions {
/// Returns a dictionary of allowed permissions for each group.
///
/// # Parameters
/// - `permissions`: \[out\] A dictionary of allowed permissions for each group.
///
/// Calls the openDAQ C function `daqPermissions_getAllowed()`.
pub fn allowed(&self) -> Result<std::collections::HashMap<String, i64>> {
let mut __permissions: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissions_getAllowed)(self.as_raw() as *mut _, &mut __permissions) };
check(__code, "daqPermissions_getAllowed")?;
Ok(unsafe { crate::marshal::take_dict::<String, i64>(__permissions as *mut _, "daqPermissions_getAllowed") }?)
}
/// Returns a dictionary of denied permissions for each group.
///
/// # Parameters
/// - `permissions`: \[out\] A dictionary of denied permissions for each group.
///
/// Calls the openDAQ C function `daqPermissions_getDenied()`.
pub fn denied(&self) -> Result<std::collections::HashMap<String, i64>> {
let mut __permissions: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPermissions_getDenied)(self.as_raw() as *mut _, &mut __permissions) };
check(__code, "daqPermissions_getDenied")?;
Ok(unsafe { crate::marshal::take_dict::<String, i64>(__permissions as *mut _, "daqPermissions_getDenied") }?)
}
/// Returns true if an object should inherit permissions from its parent object.
///
/// # Parameters
/// - `is_inherited`: \[out\] True if permissions should be inherited from parent object.
///
/// Calls the openDAQ C function `daqPermissions_getInherited()`.
pub fn inherited(&self) -> Result<bool> {
let mut __is_inherited: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPermissions_getInherited)(self.as_raw() as *mut _, &mut __is_inherited) };
check(__code, "daqPermissions_getInherited")?;
Ok(__is_inherited != 0)
}
}
impl Procedure {
/// Calls the openDAQ C function `daqProcedure_dispatch()`.
pub fn dispatch(&self, params: impl Into<Value>) -> Result<()> {
let __params = crate::value::to_daq(¶ms.into())?;
let __code = unsafe { (crate::sys::api().daqProcedure_dispatch)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__params) as *mut _) };
check(__code, "daqProcedure_dispatch")?;
Ok(())
}
}
impl PropertyBuilder {
/// Builds and returns a Property using the currently set values of the Builder.
///
/// # Returns
/// - `property`: The built property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_build()`.
pub fn build(&self) -> Result<Option<Property>> {
let mut __property: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_build)(self.as_raw() as *mut _, &mut __property) };
check(__code, "daqPropertyBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<Property>(__property as *mut _) })
}
/// Creates a boolean Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The boolean default value. Can be an EvalValue. The Property Value type is `ctBool`. Note that the defaultValue parameter can be EvalValue.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createBoolPropertyBuilder()`.
pub fn bool(name: &str, default_value: bool) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::bool_to_ref(default_value)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createBoolPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_createBoolPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createBoolPropertyBuilder") }?)
}
/// Creates a dictionary Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The dictionary default value. The Property Value type is `ctDict`. The dictionary passed as default value must have homogeneous key and value lists (all dictionary keys/values must be of the same type). The Property's Item type field will be set according to defaultValue dictionary Item type. The same goes for the Key type. TODO: defaultValue can be an EvalValue once dictionaries are supported.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createDictPropertyBuilder()`.
pub fn dict(name: &str, default_value: impl Into<Value>) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::to_daq(&default_value.into())?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createDictPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__default_value) as *mut _) };
check(__code, "daqPropertyBuilder_createDictPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createDictPropertyBuilder") }?)
}
/// Creates an Enumeration Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The default structure value. The Property Value type is `ctEnumeration`.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createEnumerationPropertyBuilder()`.
pub fn enumeration(name: &str, default_value: &Enumeration) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createEnumerationPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, default_value.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_createEnumerationPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createEnumerationPropertyBuilder") }?)
}
/// Creates a floating point value Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The float default value. Can be an EvalValue The Property Value type is `ctFloat`. Note that the defaultValue parameter can be EvalValue.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createFloatPropertyBuilder()`.
pub fn float(name: &str, default_value: f64) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::float_to_ref(default_value)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createFloatPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_createFloatPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createFloatPropertyBuilder") }?)
}
/// Creates a function- or procedure-type Property builder object. Requires the a CallableInfo object to specify the argument type/count and function return type.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `callable_info`: Information about the callable argument type/count and return type. The Property Value type is `ctFunction` or `ctProc`, depending on if `callableInfo` contains information on the return type or not.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createFunctionPropertyBuilder()`.
pub fn function(name: &str, callable_info: &CallableInfo) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createFunctionPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, callable_info.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_createFunctionPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createFunctionPropertyBuilder") }?)
}
/// Creates an integer Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The integer default value. Can be an EvalValue. The Property Value type is `ctInt`. Note that the defaultValue parameter can be EvalValue.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createIntPropertyBuilder()`.
pub fn int(name: &str, default_value: i64) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::int_to_ref(default_value)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createIntPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_createIntPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createIntPropertyBuilder") }?)
}
/// Creates a list Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The list default value. Can be an EvalValue. The Property Value type is `ctList`. Note that the defaultValue parameter can be EvalValue. The list passed as `defaultValue` must be homogeneous. The Property's Item type field will be set according to defaultValue list type.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createListPropertyBuilder()`.
pub fn list(name: &str, default_value: impl Into<Value>) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::to_daq(&default_value.into())?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createListPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__default_value) as *mut _) };
check(__code, "daqPropertyBuilder_createListPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createListPropertyBuilder") }?)
}
/// Creates an object-type Property builder object with a specified name and default value..
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The Property object default value. The Property Value type is `ctObject`. Object properties cannot be have any metadata other than their name, description, and default value configured. The PropertyObject default value can only be a base PropertyObject type (not a descendant type). If the defaultValue is not specified, it will automatically be configured to an empty Property Object.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createObjectPropertyBuilder()`.
pub fn object(name: &str, default_value: &PropertyObject) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createObjectPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, default_value.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_createObjectPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createObjectPropertyBuilder") }?)
}
/// Creates an Property builder object with only the name field configured.
///
/// # Parameters
/// - `name`: The name of the Property. The default Value type is `ctUndefined`.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createPropertyBuilder()`.
pub fn new(name: &str) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_createPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createPropertyBuilder") }?)
}
/// Creates a ratio Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The ratio default value. The Property Value type is `ctRatio`. TODO: defaultValue can be an EvalValue once ratios are supported.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createRatioPropertyBuilder()`.
pub fn ratio(name: &str, default_value: Ratio) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::ratio_to_ref(default_value)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createRatioPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_createRatioPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createRatioPropertyBuilder") }?)
}
/// Creates a Reference Property builder object that points at a property specified in the `referencedProperty` parameter.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `referenced_property_eval`: The evaluation expression that evaluates to another property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createReferencePropertyBuilder()`.
pub fn reference(name: &str, referenced_property_eval: &EvalValue) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createReferencePropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, referenced_property_eval.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_createReferencePropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createReferencePropertyBuilder") }?)
}
/// Creates a Selection Property builder object with a list of selection values. The default value is an integer index into the default selected value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `selection_values`: The list of selectable values.
/// - `default_value`: The default index into the list of selection values. The Property Value type is `ctInt`.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createSelectionPropertyBuilder()`.
pub fn selection(name: &str, selection_values: impl Into<Value>, default_value: i64) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __selection_values = crate::value::to_daq(&selection_values.into())?;
let __default_value = crate::value::int_to_ref(default_value)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createSelectionPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__selection_values) as *mut _, __default_value.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_createSelectionPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createSelectionPropertyBuilder") }?)
}
/// Creates a Selection Property builder object with a dictionary of selection values. The default value is an integer key into the provided dictionary.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `selection_values`: The dictionary of selectable values. The key type must be `ctInt`.
/// - `default_value`: The default key into the list of selection values. The Property Value type is `ctInt`. The key type of the Selection values dictionary must be `ctInt`.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createSparseSelectionPropertyBuilder()`.
pub fn sparse_selection(name: &str, selection_values: impl Into<Value>, default_value: i64) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __selection_values = crate::value::to_daq(&selection_values.into())?;
let __default_value = crate::value::int_to_ref(default_value)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createSparseSelectionPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__selection_values) as *mut _, __default_value.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_createSparseSelectionPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createSparseSelectionPropertyBuilder") }?)
}
/// Creates a string Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The integer default value. Can be an EvalValue. The Property Value type is `ctString`. Note that the defaultValue parameter can be EvalValue.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createStringPropertyBuilder()`.
pub fn string(name: &str, default_value: &str) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::marshal::make_string(default_value)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createStringPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_createStringPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createStringPropertyBuilder") }?)
}
/// Creates a Struct Property builder object with a specified name and default value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The default structure value. The Property Value type is `ctStruct`.
///
/// Calls the openDAQ C function `daqPropertyBuilder_createStructPropertyBuilder()`.
pub fn struct_(name: &str, default_value: &Struct) -> Result<PropertyBuilder> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqPropertyBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_createStructPropertyBuilder)(&mut __obj, __name.as_ptr() as *mut _, default_value.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_createStructPropertyBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyBuilder>(__obj as *mut _, "daqPropertyBuilder_createStructPropertyBuilder") }?)
}
/// Gets the Callable information objects of the Property that specifies the argument and return types of the callable object stored as the Property value.
///
/// # Returns
/// - `callable`: The Callable info object.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getCallableInfo()`.
pub fn callable_info(&self) -> Result<Option<CallableInfo>> {
let mut __callable: *mut sys::daqCallableInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getCallableInfo)(self.as_raw() as *mut _, &mut __callable) };
check(__code, "daqPropertyBuilder_getCallableInfo")?;
Ok(unsafe { crate::marshal::take_object::<CallableInfo>(__callable as *mut _) })
}
/// Gets the coercer of the Property.
///
/// # Returns
/// - `coercer`: The coercer.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getCoercer()`.
pub fn coercer(&self) -> Result<Option<Coercer>> {
let mut __coercer: *mut sys::daqCoercer = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getCoercer)(self.as_raw() as *mut _, &mut __coercer) };
check(__code, "daqPropertyBuilder_getCoercer")?;
Ok(unsafe { crate::marshal::take_object::<Coercer>(__coercer as *mut _) })
}
/// Gets the Default value of the Property.
///
/// # Returns
/// - `value`: The Default value of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getDefaultValue()`.
pub fn default_value(&self) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getDefaultValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqPropertyBuilder_getDefaultValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyBuilder_getDefaultValue") }?)
}
/// Gets the short string Description of the Property.
///
/// # Returns
/// - `description`: The Description of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getDescription()`.
pub fn description(&self) -> Result<String> {
let mut __description: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getDescription)(self.as_raw() as *mut _, &mut __description) };
check(__code, "daqPropertyBuilder_getDescription")?;
Ok(unsafe { crate::marshal::take_string(__description) })
}
/// Gets the integer value selection flag for selection properties with valueType == ctInt.
/// When true, the property stores the actual selected integer value (IntegerValueSelection).
/// When false (default), the property stores the index of the selected entry (IndexSelection).
/// This flag is ignored for sparse selection properties and for selection properties
/// with a valueType other than ctInt.
///
/// # Parameters
/// - `is_integer_value_selection`: The current value of the flag.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getIsIntegerValueSelection()`.
pub fn is_integer_value_selection(&self) -> Result<bool> {
let mut __is_integer_value_selection: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getIsIntegerValueSelection)(self.as_raw() as *mut _, &mut __is_integer_value_selection) };
check(__code, "daqPropertyBuilder_getIsIntegerValueSelection")?;
Ok(__is_integer_value_selection != 0)
}
/// Gets the Maximum value of the Property. Available only if the Value type is `ctInt` or `ctFloat`.
///
/// # Returns
/// - `max`: The Maximum value of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getMaxValue()`.
pub fn max_value(&self) -> Result<Option<f64>> {
let mut __max: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getMaxValue)(self.as_raw() as *mut _, &mut __max) };
check(__code, "daqPropertyBuilder_getMaxValue")?;
Ok(unsafe { crate::value::take_number(__max, "daqPropertyBuilder_getMaxValue") }?)
}
/// Gets the Minimum value of the Property. Available only if the Value type is `ctInt` or `ctFloat`.
///
/// # Returns
/// - `min`: The Minimum value of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getMinValue()`.
pub fn min_value(&self) -> Result<Option<f64>> {
let mut __min: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getMinValue)(self.as_raw() as *mut _, &mut __min) };
check(__code, "daqPropertyBuilder_getMinValue")?;
Ok(unsafe { crate::value::take_number(__min, "daqPropertyBuilder_getMinValue") }?)
}
/// Gets the Name of the Property.
///
/// # Returns
/// - `name`: The Name of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqPropertyBuilder_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets a custom on-read event. Used mostly when cloning properties.
///
/// # Returns
/// - `event`: The on-read event.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getOnPropertyValueRead()`.
pub fn on_property_value_read(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getOnPropertyValueRead)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyBuilder_getOnPropertyValueRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets a custom on-write event. Used mostly when cloning properties.
///
/// # Returns
/// - `event`: The on-write event.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getOnPropertyValueWrite()`.
pub fn on_property_value_write(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getOnPropertyValueWrite)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyBuilder_getOnPropertyValueWrite")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets a custom on-selection-values-read event. Used mostly when cloning properties.
///
/// # Parameters
/// - `event`: The on-read event.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getOnSelectionValuesRead()`.
pub fn on_selection_values_read(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getOnSelectionValuesRead)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyBuilder_getOnSelectionValuesRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets a custom on-suggested-values-read event. Used mostly when cloning properties.
///
/// # Parameters
/// - `event`: The on-read event.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getOnSuggestedValuesRead()`.
pub fn on_suggested_values_read(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getOnSuggestedValuesRead)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyBuilder_getOnSuggestedValuesRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Used to determine whether the Property is a read-only property or not.
///
/// # Returns
/// - `read_only`: True if the Property is a read-only property; false otherwise.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getReadOnly()`.
pub fn read_only(&self) -> Result<Option<bool>> {
let mut __read_only: *mut sys::daqBoolean = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getReadOnly)(self.as_raw() as *mut _, &mut __read_only) };
check(__code, "daqPropertyBuilder_getReadOnly")?;
Ok(unsafe { crate::value::take_boxed_bool(__read_only, "daqPropertyBuilder_getReadOnly") }?)
}
/// Gets the referenced property.
///
/// # Returns
/// - `property_eval`: The referenced property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getReferencedProperty()`.
pub fn referenced_property(&self) -> Result<Option<EvalValue>> {
let mut __property_eval: *mut sys::daqEvalValue = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getReferencedProperty)(self.as_raw() as *mut _, &mut __property_eval) };
check(__code, "daqPropertyBuilder_getReferencedProperty")?;
Ok(unsafe { crate::marshal::take_object::<EvalValue>(__property_eval as *mut _) })
}
/// Gets the list or dictionary of selection values.
///
/// # Returns
/// - `values`: The list/dictionary of possible selection values.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getSelectionValues()`.
pub fn selection_values(&self) -> Result<Value> {
let mut __values: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getSelectionValues)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqPropertyBuilder_getSelectionValues")?;
Ok(unsafe { crate::value::take_value(__values, "daqPropertyBuilder_getSelectionValues") }?)
}
/// Gets the list of Suggested values. Contains values that are the optimal gettings for the corresponding Property value. These values, however, are not enforced when getting a new Property value.
///
/// # Returns
/// - `values`: The Suggested values of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getSuggestedValues()`.
pub fn suggested_values(&self) -> Result<Vec<Value>> {
let mut __values: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getSuggestedValues)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqPropertyBuilder_getSuggestedValues")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__values as *mut _, "daqPropertyBuilder_getSuggestedValues") }?)
}
/// Gets the Unit of the Property.
///
/// # Returns
/// - `unit`: The Unit of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getUnit()`.
pub fn unit(&self) -> Result<Option<Unit>> {
let mut __unit: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getUnit)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqPropertyBuilder_getUnit")?;
Ok(unsafe { crate::marshal::take_object::<Unit>(__unit as *mut _) })
}
/// Gets the validator of the Property.
///
/// # Returns
/// - `validator`: The validator.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getValidator()`.
pub fn validator(&self) -> Result<Option<Validator>> {
let mut __validator: *mut sys::daqValidator = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getValidator)(self.as_raw() as *mut _, &mut __validator) };
check(__code, "daqPropertyBuilder_getValidator")?;
Ok(unsafe { crate::marshal::take_object::<Validator>(__validator as *mut _) })
}
/// Gets the Value type of the Property.
///
/// # Returns
/// - `type`: The value type.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getValueType()`.
pub fn value_type(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getValueType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqPropertyBuilder_getValueType")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqPropertyBuilder_getValueType")?)
}
/// Used to determine whether the property is visible or not.
///
/// # Returns
/// - `visible`: True if the Property is visible; false otherwise.
///
/// Calls the openDAQ C function `daqPropertyBuilder_getVisible()`.
pub fn visible(&self) -> Result<Option<bool>> {
let mut __visible: *mut sys::daqBoolean = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_getVisible)(self.as_raw() as *mut _, &mut __visible) };
check(__code, "daqPropertyBuilder_getVisible")?;
Ok(unsafe { crate::value::take_boxed_bool(__visible, "daqPropertyBuilder_getVisible") }?)
}
/// Sets the Callable information objects of the Property that specifies the argument and return types of the callable object stored as the Property value.
///
/// # Parameters
/// - `callable`: The Callable info object.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setCallableInfo()`.
pub fn set_callable_info(&self, callable: &CallableInfo) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setCallableInfo)(self.as_raw() as *mut _, callable.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setCallableInfo")?;
Ok(())
}
/// Sets the coercer of the Property.
///
/// # Parameters
/// - `coercer`: The coercer. Used to coerce a value written to the corresponding Property value to the constraints specified by the coercer.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setCoercer()`.
pub fn set_coercer(&self, coercer: &Coercer) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setCoercer)(self.as_raw() as *mut _, coercer.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setCoercer")?;
Ok(())
}
/// Sets the Default value of the Property. The Default value must always be configured for a Property to be in a valid state. Exceptions are Function/Procedure and Reference properties. The function will freeze default value if it is freezable.
///
/// # Parameters
/// - `value`: The Default value of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setDefaultValue()`.
pub fn set_default_value(&self, value: impl Into<Value>) -> Result<()> {
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setDefaultValue)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqPropertyBuilder_setDefaultValue")?;
Ok(())
}
/// Sets the short string Description of the Property.
///
/// # Parameters
/// - `description`: The Description of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setDescription()`.
pub fn set_description(&self, description: &str) -> Result<()> {
let __description = crate::marshal::make_string(description)?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setDescription)(self.as_raw() as *mut _, __description.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_setDescription")?;
Ok(())
}
/// Sets the integer value selection flag for selection properties with valueType == ctInt.
/// When true, the property stores the actual selected integer value (IntegerValueSelection).
/// When false (default), the property stores the index of the selected entry (IndexSelection).
/// This flag is ignored for sparse selection properties and for selection properties
/// with a valueType other than ctInt.
///
/// # Parameters
/// - `is_integer_value_selection`: True to store the selected value; false to store the selection index.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setIsIntegerValueSelection()`.
pub fn set_is_integer_value_selection(&self, is_integer_value_selection: bool) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setIsIntegerValueSelection)(self.as_raw() as *mut _, u8::from(is_integer_value_selection)) };
check(__code, "daqPropertyBuilder_setIsIntegerValueSelection")?;
Ok(())
}
/// Sets the Maximum value of the Property. Available only if the Value type is `ctInt` or `ctFloat`.
///
/// # Parameters
/// - `max`: The Maximum value of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setMaxValue()`.
pub fn set_max_value(&self, max: impl Into<Value>) -> Result<()> {
let __max = crate::value::to_daq_number(&max.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setMaxValue)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__max) as *mut _) };
check(__code, "daqPropertyBuilder_setMaxValue")?;
Ok(())
}
/// Sets the Minimum value of the Property. Available only if the Value type is `ctInt` or `ctFloat`.
///
/// # Parameters
/// - `min`: The Minimum value of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setMinValue()`.
pub fn set_min_value(&self, min: impl Into<Value>) -> Result<()> {
let __min = crate::value::to_daq_number(&min.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setMinValue)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__min) as *mut _) };
check(__code, "daqPropertyBuilder_setMinValue")?;
Ok(())
}
/// Sets the Name of the Property. The names of Properties in a Property object must be unique. The name is used as the key to the corresponding Property value when getting/setting the value.
///
/// # Parameters
/// - `name`: The Name of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setName()`.
pub fn set_name(&self, name: &str) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setName)(self.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_setName")?;
Ok(())
}
/// Sets a custom on-read event. Used mostly when cloning properties.
///
/// # Parameters
/// - `event`: The on-read event.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setOnPropertyValueRead()`.
pub fn set_on_property_value_read(&self, event: &Event) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setOnPropertyValueRead)(self.as_raw() as *mut _, event.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setOnPropertyValueRead")?;
Ok(())
}
/// Sets a custom on-write event. Used mostly when cloning properties.
///
/// # Parameters
/// - `event`: The on-write event.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setOnPropertyValueWrite()`.
pub fn set_on_property_value_write(&self, event: &Event) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setOnPropertyValueWrite)(self.as_raw() as *mut _, event.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setOnPropertyValueWrite")?;
Ok(())
}
/// Sets a custom on-selection-values-read event. Used mostly when cloning properties.
///
/// # Parameters
/// - `event`: The on-read event.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setOnSelectionValuesRead()`.
pub fn set_on_selection_values_read(&self, event: &Event) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setOnSelectionValuesRead)(self.as_raw() as *mut _, event.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setOnSelectionValuesRead")?;
Ok(())
}
/// Sets a custom on-suggested-values-read event. Used mostly when cloning properties.
///
/// # Parameters
/// - `event`: The on-read event.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setOnSuggestedValuesRead()`.
pub fn set_on_suggested_values_read(&self, event: &Event) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setOnSuggestedValuesRead)(self.as_raw() as *mut _, event.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setOnSuggestedValuesRead")?;
Ok(())
}
/// Used to determine whether the Property is a read-only property or not.
///
/// # Parameters
/// - `read_only`: True if the Property is a read-only property; false otherwise. Read-only Property values can still be modified by using the `PropertyObjectProtected` interface methods.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setReadOnly()`.
pub fn set_read_only(&self, read_only: bool) -> Result<()> {
let __read_only = crate::value::bool_to_ref(read_only)?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setReadOnly)(self.as_raw() as *mut _, __read_only.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_setReadOnly")?;
Ok(())
}
/// Sets the referenced property. If set, all getters except for the `Name`, `Referenced property`, and `Is referenced` getters will return the value of the `Referenced property`.
///
/// # Parameters
/// - `property_eval`: The referenced property. If the Property is not bound to a Property object this call will not be able to return the Referenced property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setReferencedProperty()`.
pub fn set_referenced_property(&self, property_eval: &EvalValue) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setReferencedProperty)(self.as_raw() as *mut _, property_eval.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setReferencedProperty")?;
Ok(())
}
/// Sets the list or dictionary of selection values. If the list/dictionary is not empty, the property is a Selection property, and must have the Value type `ctInt`.
///
/// # Parameters
/// - `values`: The list/dictionary of possible selection values.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setSelectionValues()`.
pub fn set_selection_values(&self, values: impl Into<Value>) -> Result<()> {
let __values = crate::value::to_daq(&values.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setSelectionValues)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__values) as *mut _) };
check(__code, "daqPropertyBuilder_setSelectionValues")?;
Ok(())
}
/// Sets the list of Suggested values. Contains values that are the optimal settings for the corresponding Property value. These values, however, are not enforced when setting a new Property value.
///
/// # Parameters
/// - `values`: The Suggested values of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setSuggestedValues()`.
pub fn set_suggested_values(&self, values: impl Into<Value>) -> Result<()> {
let __values = crate::value::to_daq(&values.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setSuggestedValues)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__values) as *mut _) };
check(__code, "daqPropertyBuilder_setSuggestedValues")?;
Ok(())
}
/// Sets the Unit of the Property.
///
/// # Parameters
/// - `unit`: The Unit of the Property.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setUnit()`.
pub fn set_unit(&self, unit: &Unit) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setUnit)(self.as_raw() as *mut _, unit.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setUnit")?;
Ok(())
}
/// Sets the validator of the Property.
///
/// # Parameters
/// - `validator`: The validator. Used to validate whether a value written to the corresponding Property value is valid or not.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setValidator()`.
pub fn set_validator(&self, validator: &Validator) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setValidator)(self.as_raw() as *mut _, validator.as_raw() as *mut _) };
check(__code, "daqPropertyBuilder_setValidator")?;
Ok(())
}
/// Sets the Value type of the Property. Values written to the corresponding Property value must be of the same type.
///
/// # Parameters
/// - `type`: The value type.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setValueType()`.
pub fn set_value_type(&self, type_: CoreType) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setValueType)(self.as_raw() as *mut _, type_ as u32) };
check(__code, "daqPropertyBuilder_setValueType")?;
Ok(())
}
/// Used to determine whether the property is visible or not.
///
/// # Parameters
/// - `visible`: True if the Property is visible; false otherwise.
///
/// Calls the openDAQ C function `daqPropertyBuilder_setVisible()`.
pub fn set_visible(&self, visible: bool) -> Result<()> {
let __visible = crate::value::bool_to_ref(visible)?;
let __code = unsafe { (crate::sys::api().daqPropertyBuilder_setVisible)(self.as_raw() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqPropertyBuilder_setVisible")?;
Ok(())
}
}
impl PropertyInternal {
/// Clones the property without an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_clone()`.
pub fn clone_object(&self) -> Result<Option<Property>> {
let mut __cloned_property: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_clone)(self.as_raw() as *mut _, &mut __cloned_property) };
check(__code, "daqPropertyInternal_clone")?;
Ok(unsafe { crate::marshal::take_object::<Property>(__cloned_property as *mut _) })
}
/// Clones the property, setting the passed PropertyObject as its owner.
/// If the provided owner is the same as the current owner of the property, the property is not cloned.
/// Instead the property itself is returned as-is.
///
/// Calls the openDAQ C function `daqPropertyInternal_cloneWithOwner()`.
pub fn clone_with_owner(&self, owner: &PropertyObject) -> Result<Option<Property>> {
let mut __cloned_property: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_cloneWithOwner)(self.as_raw() as *mut _, owner.as_raw() as *mut _, &mut __cloned_property) };
check(__code, "daqPropertyInternal_cloneWithOwner")?;
Ok(unsafe { crate::marshal::take_object::<Property>(__cloned_property as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getCallableInfoNoLock()`.
pub fn callable_info_no_lock(&self) -> Result<Option<CallableInfo>> {
let mut __callable: *mut sys::daqCallableInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getCallableInfoNoLock)(self.as_raw() as *mut _, &mut __callable) };
check(__code, "daqPropertyInternal_getCallableInfoNoLock")?;
Ok(unsafe { crate::marshal::take_object::<CallableInfo>(__callable as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getClassOnPropertyValueRead()`.
pub fn class_on_property_value_read(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getClassOnPropertyValueRead)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyInternal_getClassOnPropertyValueRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getClassOnPropertyValueWrite()`.
pub fn class_on_property_value_write(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getClassOnPropertyValueWrite)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyInternal_getClassOnPropertyValueWrite")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getCoercerNoLock()`.
pub fn coercer_no_lock(&self) -> Result<Option<Coercer>> {
let mut __coercer: *mut sys::daqCoercer = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getCoercerNoLock)(self.as_raw() as *mut _, &mut __coercer) };
check(__code, "daqPropertyInternal_getCoercerNoLock")?;
Ok(unsafe { crate::marshal::take_object::<Coercer>(__coercer as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getDefaultValueNoLock()`.
pub fn default_value_no_lock(&self) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getDefaultValueNoLock)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqPropertyInternal_getDefaultValueNoLock")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyInternal_getDefaultValueNoLock") }?)
}
/// Gets the Property default value in an as either a BaseObject or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getDefaultValueUnresolved()`.
pub fn default_value_unresolved(&self) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getDefaultValueUnresolved)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqPropertyInternal_getDefaultValueUnresolved")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyInternal_getDefaultValueUnresolved") }?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getDescriptionNoLock()`.
pub fn description_no_lock(&self) -> Result<String> {
let mut __description: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getDescriptionNoLock)(self.as_raw() as *mut _, &mut __description) };
check(__code, "daqPropertyInternal_getDescriptionNoLock")?;
Ok(unsafe { crate::marshal::take_string(__description) })
}
/// Gets the Property description in an as either a String or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getDescriptionUnresolved()`.
pub fn description_unresolved(&self) -> Result<String> {
let mut __description: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getDescriptionUnresolved)(self.as_raw() as *mut _, &mut __description) };
check(__code, "daqPropertyInternal_getDescriptionUnresolved")?;
Ok(unsafe { crate::marshal::take_string(__description) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getHasOnGetSelectionValuesListeners()`.
pub fn has_on_get_selection_values_listeners(&self) -> Result<bool> {
let mut __has_listeners: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getHasOnGetSelectionValuesListeners)(self.as_raw() as *mut _, &mut __has_listeners) };
check(__code, "daqPropertyInternal_getHasOnGetSelectionValuesListeners")?;
Ok(__has_listeners != 0)
}
/// Calls the openDAQ C function `daqPropertyInternal_getHasOnGetSuggestedValuesListeners()`.
pub fn has_on_get_suggested_values_listeners(&self) -> Result<bool> {
let mut __has_listeners: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getHasOnGetSuggestedValuesListeners)(self.as_raw() as *mut _, &mut __has_listeners) };
check(__code, "daqPropertyInternal_getHasOnGetSuggestedValuesListeners")?;
Ok(__has_listeners != 0)
}
/// Calls the openDAQ C function `daqPropertyInternal_getHasOnReadListeners()`.
pub fn has_on_read_listeners(&self) -> Result<bool> {
let mut __has_listeners: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getHasOnReadListeners)(self.as_raw() as *mut _, &mut __has_listeners) };
check(__code, "daqPropertyInternal_getHasOnReadListeners")?;
Ok(__has_listeners != 0)
}
/// Calls the openDAQ C function `daqPropertyInternal_getIsReferencedNoLock()`.
pub fn is_referenced_no_lock(&self) -> Result<bool> {
let mut __is_referenced: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getIsReferencedNoLock)(self.as_raw() as *mut _, &mut __is_referenced) };
check(__code, "daqPropertyInternal_getIsReferencedNoLock")?;
Ok(__is_referenced != 0)
}
/// Calls the openDAQ C function `daqPropertyInternal_getItemTypeNoLock()`.
pub fn item_type_no_lock(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getItemTypeNoLock)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqPropertyInternal_getItemTypeNoLock")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqPropertyInternal_getItemTypeNoLock")?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getKeyTypeNoLock()`.
pub fn key_type_no_lock(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getKeyTypeNoLock)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqPropertyInternal_getKeyTypeNoLock")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqPropertyInternal_getKeyTypeNoLock")?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getMaxValueNoLock()`.
pub fn max_value_no_lock(&self) -> Result<Option<f64>> {
let mut __max: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getMaxValueNoLock)(self.as_raw() as *mut _, &mut __max) };
check(__code, "daqPropertyInternal_getMaxValueNoLock")?;
Ok(unsafe { crate::value::take_number(__max, "daqPropertyInternal_getMaxValueNoLock") }?)
}
/// Gets the Property max value in an as either a Number or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getMaxValueUnresolved()`.
pub fn max_value_unresolved(&self) -> Result<Option<f64>> {
let mut __max: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getMaxValueUnresolved)(self.as_raw() as *mut _, &mut __max) };
check(__code, "daqPropertyInternal_getMaxValueUnresolved")?;
Ok(unsafe { crate::value::take_number(__max, "daqPropertyInternal_getMaxValueUnresolved") }?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getMinValueNoLock()`.
pub fn min_value_no_lock(&self) -> Result<Option<f64>> {
let mut __min: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getMinValueNoLock)(self.as_raw() as *mut _, &mut __min) };
check(__code, "daqPropertyInternal_getMinValueNoLock")?;
Ok(unsafe { crate::value::take_number(__min, "daqPropertyInternal_getMinValueNoLock") }?)
}
/// Gets the Property min value in an as either a Number or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getMinValueUnresolved()`.
pub fn min_value_unresolved(&self) -> Result<Option<f64>> {
let mut __min: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getMinValueUnresolved)(self.as_raw() as *mut _, &mut __min) };
check(__code, "daqPropertyInternal_getMinValueUnresolved")?;
Ok(unsafe { crate::value::take_number(__min, "daqPropertyInternal_getMinValueUnresolved") }?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getReadOnlyNoLock()`.
pub fn read_only_no_lock(&self) -> Result<bool> {
let mut __read_only: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getReadOnlyNoLock)(self.as_raw() as *mut _, &mut __read_only) };
check(__code, "daqPropertyInternal_getReadOnlyNoLock")?;
Ok(__read_only != 0)
}
/// Gets the Property read-only field in an as either a Boolean or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getReadOnlyUnresolved()`.
pub fn read_only_unresolved(&self) -> Result<Option<bool>> {
let mut __read_only: *mut sys::daqBoolean = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getReadOnlyUnresolved)(self.as_raw() as *mut _, &mut __read_only) };
check(__code, "daqPropertyInternal_getReadOnlyUnresolved")?;
Ok(unsafe { crate::value::take_boxed_bool(__read_only, "daqPropertyInternal_getReadOnlyUnresolved") }?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getReferencedPropertyNoLock()`.
pub fn referenced_property_no_lock(&self) -> Result<Option<Property>> {
let mut __property_eval: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getReferencedPropertyNoLock)(self.as_raw() as *mut _, &mut __property_eval) };
check(__code, "daqPropertyInternal_getReferencedPropertyNoLock")?;
Ok(unsafe { crate::marshal::take_object::<Property>(__property_eval as *mut _) })
}
/// Gets the Property referenced property in an as either a Property or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getReferencedPropertyUnresolved()`.
pub fn referenced_property_unresolved(&self) -> Result<Option<EvalValue>> {
let mut __property_eval: *mut sys::daqEvalValue = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getReferencedPropertyUnresolved)(self.as_raw() as *mut _, &mut __property_eval) };
check(__code, "daqPropertyInternal_getReferencedPropertyUnresolved")?;
Ok(unsafe { crate::marshal::take_object::<EvalValue>(__property_eval as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getSelectionValuesNoLock()`.
pub fn selection_values_no_lock(&self) -> Result<Value> {
let mut __values: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getSelectionValuesNoLock)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqPropertyInternal_getSelectionValuesNoLock")?;
Ok(unsafe { crate::value::take_value(__values, "daqPropertyInternal_getSelectionValuesNoLock") }?)
}
/// Gets the Property selection values in an as either a Dictionary of Int-BaseObject pairs, List of BaseObjects, or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getSelectionValuesUnresolved()`.
pub fn selection_values_unresolved(&self) -> Result<Value> {
let mut __values: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getSelectionValuesUnresolved)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqPropertyInternal_getSelectionValuesUnresolved")?;
Ok(unsafe { crate::value::take_value(__values, "daqPropertyInternal_getSelectionValuesUnresolved") }?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getStructTypeNoLock()`.
pub fn struct_type_no_lock(&self) -> Result<Option<StructType>> {
let mut __struct_type: *mut sys::daqStructType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getStructTypeNoLock)(self.as_raw() as *mut _, &mut __struct_type) };
check(__code, "daqPropertyInternal_getStructTypeNoLock")?;
Ok(unsafe { crate::marshal::take_object::<StructType>(__struct_type as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getSuggestedValuesNoLock()`.
pub fn suggested_values_no_lock(&self) -> Result<Vec<Value>> {
let mut __values: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getSuggestedValuesNoLock)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqPropertyInternal_getSuggestedValuesNoLock")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__values as *mut _, "daqPropertyInternal_getSuggestedValuesNoLock") }?)
}
/// Gets the Property suggested values in an as either a List of BaseObjects or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getSuggestedValuesUnresolved()`.
pub fn suggested_values_unresolved(&self) -> Result<Vec<Value>> {
let mut __values: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getSuggestedValuesUnresolved)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqPropertyInternal_getSuggestedValuesUnresolved")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__values as *mut _, "daqPropertyInternal_getSuggestedValuesUnresolved") }?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getUnitNoLock()`.
pub fn unit_no_lock(&self) -> Result<Option<Unit>> {
let mut __unit: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getUnitNoLock)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqPropertyInternal_getUnitNoLock")?;
Ok(unsafe { crate::marshal::take_object::<Unit>(__unit as *mut _) })
}
/// Gets the Property unit in an as either a String (TODO: as an IUnit once supported) or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getUnitUnresolved()`.
pub fn unit_unresolved(&self) -> Result<Value> {
let mut __unit: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getUnitUnresolved)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqPropertyInternal_getUnitUnresolved")?;
Ok(unsafe { crate::value::take_value(__unit, "daqPropertyInternal_getUnitUnresolved") }?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getValidatorNoLock()`.
pub fn validator_no_lock(&self) -> Result<Option<Validator>> {
let mut __validator: *mut sys::daqValidator = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getValidatorNoLock)(self.as_raw() as *mut _, &mut __validator) };
check(__code, "daqPropertyInternal_getValidatorNoLock")?;
Ok(unsafe { crate::marshal::take_object::<Validator>(__validator as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyInternal_getValueTypeNoLock()`.
pub fn value_type_no_lock(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getValueTypeNoLock)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqPropertyInternal_getValueTypeNoLock")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqPropertyInternal_getValueTypeNoLock")?)
}
/// Gets the unresolved type of the Property
///
/// Calls the openDAQ C function `daqPropertyInternal_getValueTypeUnresolved()`.
pub fn value_type_unresolved(&self) -> Result<CoreType> {
let mut __core_type: u32 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getValueTypeUnresolved)(self.as_raw() as *mut _, &mut __core_type) };
check(__code, "daqPropertyInternal_getValueTypeUnresolved")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__core_type), "daqPropertyInternal_getValueTypeUnresolved")?)
}
/// Calls the openDAQ C function `daqPropertyInternal_getVisibleNoLock()`.
pub fn visible_no_lock(&self) -> Result<bool> {
let mut __visible: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getVisibleNoLock)(self.as_raw() as *mut _, &mut __visible) };
check(__code, "daqPropertyInternal_getVisibleNoLock")?;
Ok(__visible != 0)
}
/// Gets the Property visible field in an as either a Boolean or unresolved EvalValue. The EvalValue is bound to the owner, if the Property has an owner.
///
/// Calls the openDAQ C function `daqPropertyInternal_getVisibleUnresolved()`.
pub fn visible_unresolved(&self) -> Result<Option<bool>> {
let mut __visible: *mut sys::daqBoolean = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyInternal_getVisibleUnresolved)(self.as_raw() as *mut _, &mut __visible) };
check(__code, "daqPropertyInternal_getVisibleUnresolved")?;
Ok(unsafe { crate::value::take_boxed_bool(__visible, "daqPropertyInternal_getVisibleUnresolved") }?)
}
/// Calls the openDAQ C function `daqPropertyInternal_overrideDefaultValue()`.
pub fn override_default_value(&self, new_default_value: impl Into<Value>) -> Result<()> {
let __new_default_value = crate::value::to_daq(&new_default_value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_overrideDefaultValue)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__new_default_value) as *mut _) };
check(__code, "daqPropertyInternal_overrideDefaultValue")?;
Ok(())
}
/// Calls the openDAQ C function `daqPropertyInternal_setValueProtected()`.
pub fn set_value_protected(&self, new_value: impl Into<Value>) -> Result<()> {
let __new_value = crate::value::to_daq(&new_value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyInternal_setValueProtected)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__new_value) as *mut _) };
check(__code, "daqPropertyInternal_setValueProtected")?;
Ok(())
}
}
impl PropertyObjectClassBuilder {
/// Adds a property to the class.
///
/// # Parameters
/// - `property`: The property to be added.
///
/// # Errors
/// - `OPENDAQ_ERR_ALREADYEXISTS`: if a property with the same name already added to the class.
/// - `OPENDAQ_ERR_INVALIDTYPE`: if the property is an object type and is not atomic. The default value of object-type properties that are added to a class are frozen once added.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_addProperty()`.
pub fn add_property(&self, property: &Property) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_addProperty)(self.as_raw() as *mut _, property.as_raw() as *mut _) };
check(__code, "daqPropertyObjectClassBuilder_addProperty")?;
Ok(())
}
/// Builds and returns a Property object class using the currently set values of the Builder.
///
/// # Returns
/// - `property_object_class`: The built Property object class.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_build()`.
pub fn build(&self) -> Result<Option<PropertyObjectClass>> {
let mut __property_object_class: *mut sys::daqPropertyObjectClass = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_build)(self.as_raw() as *mut _, &mut __property_object_class) };
check(__code, "daqPropertyObjectClassBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<PropertyObjectClass>(__property_object_class as *mut _) })
}
/// Creates a property object class configuration object with a given name.
///
/// # Parameters
/// - `name`: The name of the class.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_createPropertyObjectClassBuilder()`.
pub fn new(name: &str) -> Result<PropertyObjectClassBuilder> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqPropertyObjectClassBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_createPropertyObjectClassBuilder)(&mut __obj, __name.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectClassBuilder_createPropertyObjectClassBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyObjectClassBuilder>(__obj as *mut _, "daqPropertyObjectClassBuilder_createPropertyObjectClassBuilder") }?)
}
/// Creates a Property object class configuration object with a given name, and a reference to the Type manager.
///
/// # Parameters
/// - `manager`: The Property object class manager object.
/// - `name`: The name of the class.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_createPropertyObjectClassBuilderWithManager()`.
pub fn with_manager(manager: &TypeManager, name: &str) -> Result<PropertyObjectClassBuilder> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqPropertyObjectClassBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_createPropertyObjectClassBuilderWithManager)(&mut __obj, manager.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectClassBuilder_createPropertyObjectClassBuilderWithManager")?;
Ok(unsafe { crate::marshal::require_object::<PropertyObjectClassBuilder>(__obj as *mut _, "daqPropertyObjectClassBuilder_createPropertyObjectClassBuilderWithManager") }?)
}
/// Gets a type manager
///
/// # Returns
/// - `manager`: a type manager
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_getManager()`.
pub fn manager(&self) -> Result<Option<TypeManager>> {
let mut __manager: *mut sys::daqTypeManager = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_getManager)(self.as_raw() as *mut _, &mut __manager) };
check(__code, "daqPropertyObjectClassBuilder_getManager")?;
Ok(unsafe { crate::marshal::take_object::<TypeManager>(__manager as *mut _) })
}
/// Gets the name of the property class.
///
/// # Returns
/// - `class_name`: The name of the class.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_getName()`.
pub fn name(&self) -> Result<String> {
let mut __class_name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_getName)(self.as_raw() as *mut _, &mut __class_name) };
check(__code, "daqPropertyObjectClassBuilder_getName")?;
Ok(unsafe { crate::marshal::take_string(__class_name) })
}
/// Gets the name of the parent of the property class.
///
/// # Returns
/// - `parent_name`: The parent class's name.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_getParentName()`.
pub fn parent_name(&self) -> Result<String> {
let mut __parent_name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_getParentName)(self.as_raw() as *mut _, &mut __parent_name) };
check(__code, "daqPropertyObjectClassBuilder_getParentName")?;
Ok(unsafe { crate::marshal::take_string(__parent_name) })
}
/// Gets the dictionary of properties
///
/// # Returns
/// - `properties`: dictionary of properties
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_getProperties()`.
pub fn properties(&self) -> Result<std::collections::HashMap<String, Property>> {
let mut __properties: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_getProperties)(self.as_raw() as *mut _, &mut __properties) };
check(__code, "daqPropertyObjectClassBuilder_getProperties")?;
Ok(unsafe { crate::marshal::take_dict::<String, Property>(__properties as *mut _, "daqPropertyObjectClassBuilder_getProperties") }?)
}
/// Gets a custom order of properties as defined in the list of property names.
///
/// # Returns
/// - `ordered_property_names`: A list of names of properties. The order of the list is applied to the class's properties.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_getPropertyOrder()`.
pub fn property_order(&self) -> Result<Vec<String>> {
let mut __ordered_property_names: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_getPropertyOrder)(self.as_raw() as *mut _, &mut __ordered_property_names) };
check(__code, "daqPropertyObjectClassBuilder_getPropertyOrder")?;
Ok(unsafe { crate::marshal::take_list::<String>(__ordered_property_names as *mut _, "daqPropertyObjectClassBuilder_getPropertyOrder") }?)
}
/// Removes a property with the given name from the class.
///
/// # Parameters
/// - `property_name`: The name of the property to be removed.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if the property with `propertyName` is not a member of the class.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_removeProperty()`.
pub fn remove_property(&self, property_name: &str) -> Result<()> {
let __property_name = crate::marshal::make_string(property_name)?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_removeProperty)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectClassBuilder_removeProperty")?;
Ok(())
}
/// Sets the name of the property class.
///
/// # Parameters
/// - `class_name`: The name of the class.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_setName()`.
pub fn set_name(&self, class_name: &str) -> Result<()> {
let __class_name = crate::marshal::make_string(class_name)?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_setName)(self.as_raw() as *mut _, __class_name.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectClassBuilder_setName")?;
Ok(())
}
/// Gets the name of the parent of the property class.
///
/// # Parameters
/// - `parent_name`: The parent class's name.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_setParentName()`.
pub fn set_parent_name(&self, parent_name: &str) -> Result<()> {
let __parent_name = crate::marshal::make_string(parent_name)?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_setParentName)(self.as_raw() as *mut _, __parent_name.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectClassBuilder_setParentName")?;
Ok(())
}
/// Sets a custom order of properties as defined in the list of property names.
///
/// # Parameters
/// - `ordered_property_names`: A list of names of properties. The order of the list is applied to the class's properties. The list should contain names of properties available in the class. When retrieving the class's properties, they will be sorted in the order in which the names appear in the provided list. Any class properties not in the custom order are kept in insertion order at the end of the class's list of properties.
///
/// Calls the openDAQ C function `daqPropertyObjectClassBuilder_setPropertyOrder()`.
pub fn set_property_order(&self, ordered_property_names: &[&str]) -> Result<()> {
let __ordered_property_names = crate::marshal::list_from_strs(ordered_property_names)?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassBuilder_setPropertyOrder)(self.as_raw() as *mut _, __ordered_property_names.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectClassBuilder_setPropertyOrder")?;
Ok(())
}
}
impl PropertyObjectClassInternal {
/// Clones the property object class.
///
/// # Parameters
/// - `type_manager`: The type manager to use for the cloned property object class. if type manager is not provided, cloned class will store a type manager from the original class.
///
/// # Returns
/// - `cloned`: The cloned property object class.
///
/// Calls the openDAQ C function `daqPropertyObjectClassInternal_clone()`.
pub fn clone_object(&self) -> Result<Option<PropertyObjectClass>> {
let mut __cloned: *mut sys::daqPropertyObjectClass = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassInternal_clone)(self.as_raw() as *mut _, &mut __cloned, std::ptr::null_mut()) };
check(__code, "daqPropertyObjectClassInternal_clone")?;
Ok(unsafe { crate::marshal::take_object::<PropertyObjectClass>(__cloned as *mut _) })
}
/// Clones the property object class.
///
/// # Parameters
/// - `type_manager`: The type manager to use for the cloned property object class. if type manager is not provided, cloned class will store a type manager from the original class.
///
/// # Returns
/// - `cloned`: The cloned property object class.
///
/// Calls the openDAQ C function `daqPropertyObjectClassInternal_clone()`.
pub fn clone_object_with(&self, type_manager: Option<&TypeManager>) -> Result<Option<PropertyObjectClass>> {
let mut __cloned: *mut sys::daqPropertyObjectClass = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClassInternal_clone)(self.as_raw() as *mut _, &mut __cloned, type_manager.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _)) };
check(__code, "daqPropertyObjectClassInternal_clone")?;
Ok(unsafe { crate::marshal::take_object::<PropertyObjectClass>(__cloned as *mut _) })
}
}
impl PropertyObjectClass {
/// Creates a PropertyObjectClass using Builder
///
/// # Parameters
/// - `builder`: PropertyObjectClass Builder
///
/// Calls the openDAQ C function `daqPropertyObjectClass_createPropertyObjectClassFromBuilder()`.
pub fn from_builder(builder: &PropertyObjectClassBuilder) -> Result<PropertyObjectClass> {
let mut __obj: *mut sys::daqPropertyObjectClass = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClass_createPropertyObjectClassFromBuilder)(&mut __obj, builder.as_raw() as *mut _) };
check(__code, "daqPropertyObjectClass_createPropertyObjectClassFromBuilder")?;
Ok(unsafe { crate::marshal::require_object::<PropertyObjectClass>(__obj as *mut _, "daqPropertyObjectClass_createPropertyObjectClassFromBuilder") }?)
}
/// Gets the name of the parent of the property class.
///
/// # Returns
/// - `parent_name`: The parent class's name.
///
/// Calls the openDAQ C function `daqPropertyObjectClass_getParentName()`.
pub fn parent_name(&self) -> Result<String> {
let mut __parent_name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClass_getParentName)(self.as_raw() as *mut _, &mut __parent_name) };
check(__code, "daqPropertyObjectClass_getParentName")?;
Ok(unsafe { crate::marshal::take_string(__parent_name) })
}
/// Gets the list of properties added to the class.
///
/// # Parameters
/// - `include_inherited`: If true, the returned list of properties also includes the properties of the class's ancestors.
///
/// # Returns
/// - `properties`: The list of properties.
///
/// # Errors
/// - `OPENDAQ_ERR_MANAGER_NOT_ASSIGNED`: if the parent name is set, but the Type manager is not available. The properties are sorted in insertion order, unless a custom sorting order is specified for the class. Any properties not listed in the custom sorting order are listed at the end of the properties list, sorted in insertion order.
///
/// Calls the openDAQ C function `daqPropertyObjectClass_getProperties()`.
pub fn properties(&self, include_inherited: bool) -> Result<Vec<Property>> {
let mut __properties: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClass_getProperties)(self.as_raw() as *mut _, u8::from(include_inherited), &mut __properties) };
check(__code, "daqPropertyObjectClass_getProperties")?;
Ok(unsafe { crate::marshal::take_list::<Property>(__properties as *mut _, "daqPropertyObjectClass_getProperties") }?)
}
/// Gets the class's property with the given name.
///
/// # Parameters
/// - `property_name`: The property's name.
///
/// # Returns
/// - `property`: The property.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if the Property with name `propertyName` is not added to the class.
/// - `OPENDAQ_ERR_MANAGER_NOT_ASSIGNED`: if the parent name is set, but the Type manager is not available.
///
/// Calls the openDAQ C function `daqPropertyObjectClass_getProperty()`.
pub fn property(&self, property_name: &str) -> Result<Option<Property>> {
let __property_name = crate::marshal::make_string(property_name)?;
let mut __property: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectClass_getProperty)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, &mut __property) };
check(__code, "daqPropertyObjectClass_getProperty")?;
Ok(unsafe { crate::marshal::take_object::<Property>(__property as *mut _) })
}
/// Checks if the property is registered.
///
/// # Parameters
/// - `property_name`: The property's name.
///
/// # Returns
/// - `has_property`: True if the property is registered, false otherwise.
///
/// # Errors
/// - `OPENDAQ_ERR_MANAGER_NOT_ASSIGNED`: if the parent name is set, but the Type manager is not available.
///
/// Calls the openDAQ C function `daqPropertyObjectClass_hasProperty()`.
pub fn has_property(&self, property_name: &str) -> Result<bool> {
let __property_name = crate::marshal::make_string(property_name)?;
let mut __has_property: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyObjectClass_hasProperty)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, &mut __has_property) };
check(__code, "daqPropertyObjectClass_hasProperty")?;
Ok(__has_property != 0)
}
}
impl PropertyObjectInternal {
/// Calls the openDAQ C function `daqPropertyObjectInternal_checkForReferences()`.
pub fn check_for_references(&self, property: &Property) -> Result<bool> {
let mut __is_referenced: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_checkForReferences)(self.as_raw() as *mut _, property.as_raw() as *mut _, &mut __is_referenced) };
check(__code, "daqPropertyObjectInternal_checkForReferences")?;
Ok(__is_referenced != 0)
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_checkForReferencesNoLock()`.
pub fn check_for_references_no_lock(&self, property: &Property) -> Result<bool> {
let mut __is_referenced: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_checkForReferencesNoLock)(self.as_raw() as *mut _, property.as_raw() as *mut _, &mut __is_referenced) };
check(__code, "daqPropertyObjectInternal_checkForReferencesNoLock")?;
Ok(__is_referenced != 0)
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_clearPropertyValueNoLock()`.
pub fn clear_property_value_no_lock(&self, name: &str) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_clearPropertyValueNoLock)(self.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectInternal_clearPropertyValueNoLock")?;
Ok(())
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_clone()`.
pub fn clone_object(&self) -> Result<Option<PropertyObject>> {
let mut __cloned: *mut sys::daqPropertyObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_clone)(self.as_raw() as *mut _, &mut __cloned) };
check(__code, "daqPropertyObjectInternal_clone")?;
Ok(unsafe { crate::marshal::take_object::<PropertyObject>(__cloned as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_disableCoreEventTrigger()`.
pub fn disable_core_event_trigger(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_disableCoreEventTrigger)(self.as_raw() as *mut _) };
check(__code, "daqPropertyObjectInternal_disableCoreEventTrigger")?;
Ok(())
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_enableCoreEventTrigger()`.
pub fn enable_core_event_trigger(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_enableCoreEventTrigger)(self.as_raw() as *mut _) };
check(__code, "daqPropertyObjectInternal_enableCoreEventTrigger")?;
Ok(())
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_getCoreEventTrigger()`.
pub fn core_event_trigger(&self) -> Result<Option<Procedure>> {
let mut __trigger: *mut sys::daqProcedure = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getCoreEventTrigger)(self.as_raw() as *mut _, &mut __trigger) };
check(__code, "daqPropertyObjectInternal_getCoreEventTrigger")?;
Ok(unsafe { crate::marshal::take_object::<Procedure>(__trigger as *mut _) })
}
/// Gets a lock guard that locks the object's mutex.
///
/// Calls the openDAQ C function `daqPropertyObjectInternal_getLockGuard()`.
pub fn lock_guard(&self) -> Result<Option<LockGuard>> {
let mut __lock_guard: *mut sys::daqLockGuard = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getLockGuard)(self.as_raw() as *mut _, &mut __lock_guard) };
check(__code, "daqPropertyObjectInternal_getLockGuard")?;
Ok(unsafe { crate::marshal::take_object::<LockGuard>(__lock_guard as *mut _) })
}
/// Gets the locking strategy of the object. The locking strategy must be set before the object gets and owner is added to a parent folder.
///
/// Calls the openDAQ C function `daqPropertyObjectInternal_getLockingStrategy()`.
pub fn locking_strategy(&self) -> Result<LockingStrategy> {
let mut __strategy: u32 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getLockingStrategy)(self.as_raw() as *mut _, &mut __strategy) };
check(__code, "daqPropertyObjectInternal_getLockingStrategy")?;
Ok(crate::marshal::enum_out(LockingStrategy::from_raw(__strategy), "daqPropertyObjectInternal_getLockingStrategy")?)
}
/// Gets the object's mutex. Returns the mutex of the closest `OwnLock` strategy ancestor if using the `InheritLock` strategy.
///
/// Calls the openDAQ C function `daqPropertyObjectInternal_getMutex()`.
pub fn mutex(&self) -> Result<Option<Mutex>> {
let mut __mutex: *mut sys::daqMutex = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getMutex)(self.as_raw() as *mut _, &mut __mutex) };
check(__code, "daqPropertyObjectInternal_getMutex")?;
Ok(unsafe { crate::marshal::take_object::<Mutex>(__mutex as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_getMutexOwner()`.
pub fn mutex_owner(&self) -> Result<Option<PropertyObjectInternal>> {
let mut __owner: *mut sys::daqPropertyObjectInternal = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getMutexOwner)(self.as_raw() as *mut _, &mut __owner) };
check(__code, "daqPropertyObjectInternal_getMutexOwner")?;
Ok(unsafe { crate::marshal::take_object::<PropertyObjectInternal>(__owner as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_getPath()`.
pub fn path(&self) -> Result<String> {
let mut __path: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getPath)(self.as_raw() as *mut _, &mut __path) };
check(__code, "daqPropertyObjectInternal_getPath")?;
Ok(unsafe { crate::marshal::take_string(__path) })
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_getPropertySelectionValueNoLock()`.
pub fn property_selection_value_no_lock(&self, name: &str) -> Result<Value> {
let __name = crate::marshal::make_string(name)?;
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getPropertySelectionValueNoLock)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, &mut __value) };
check(__code, "daqPropertyObjectInternal_getPropertySelectionValueNoLock")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyObjectInternal_getPropertySelectionValueNoLock") }?)
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_getPropertyValueNoLock()`.
pub fn property_value_no_lock(&self, name: &str) -> Result<Value> {
let __name = crate::marshal::make_string(name)?;
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getPropertyValueNoLock)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, &mut __value) };
check(__code, "daqPropertyObjectInternal_getPropertyValueNoLock")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyObjectInternal_getPropertyValueNoLock") }?)
}
/// Gets a lock guard that locks the object's mutex. The mutex is wrapped to be recursive, allowing for multiple locks to be instantiated on the same thread. Fails if a non-recursive lock was already created on this thread.
///
/// Calls the openDAQ C function `daqPropertyObjectInternal_getRecursiveLockGuard()`.
pub fn recursive_lock_guard(&self) -> Result<Option<LockGuard>> {
let mut __lock_guard: *mut sys::daqLockGuard = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_getRecursiveLockGuard)(self.as_raw() as *mut _, &mut __lock_guard) };
check(__code, "daqPropertyObjectInternal_getRecursiveLockGuard")?;
Ok(unsafe { crate::marshal::take_object::<LockGuard>(__lock_guard as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_hasUserReadAccess()`.
pub fn has_user_read_access(&self, user_context: impl Into<Value>) -> Result<bool> {
let __user_context = crate::value::to_daq(&user_context.into())?;
let mut __has_access_out: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_hasUserReadAccess)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__user_context) as *mut _, &mut __has_access_out) };
check(__code, "daqPropertyObjectInternal_hasUserReadAccess")?;
Ok(__has_access_out != 0)
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_isUpdating()`.
pub fn is_updating(&self) -> Result<bool> {
let mut __updating: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_isUpdating)(self.as_raw() as *mut _, &mut __updating) };
check(__code, "daqPropertyObjectInternal_isUpdating")?;
Ok(__updating != 0)
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_setCoreEventTrigger()`.
pub fn set_core_event_trigger(&self, trigger: &Procedure) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_setCoreEventTrigger)(self.as_raw() as *mut _, trigger.as_raw() as *mut _) };
check(__code, "daqPropertyObjectInternal_setCoreEventTrigger")?;
Ok(())
}
/// Sets the locking strategy of the object. The locking strategy must be set before the object gets and owner is added to a parent folder.
///
/// Calls the openDAQ C function `daqPropertyObjectInternal_setLockingStrategy()`.
pub fn set_locking_strategy(&self, strategy: LockingStrategy) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_setLockingStrategy)(self.as_raw() as *mut _, strategy as u32) };
check(__code, "daqPropertyObjectInternal_setLockingStrategy")?;
Ok(())
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_setPath()`.
pub fn set_path(&self, path: &str) -> Result<()> {
let __path = crate::marshal::make_string(path)?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_setPath)(self.as_raw() as *mut _, __path.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectInternal_setPath")?;
Ok(())
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_setPropertyValueNoLock()`.
pub fn set_property_value_no_lock(&self, name: &str, value: impl Into<Value>) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_setPropertyValueNoLock)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqPropertyObjectInternal_setPropertyValueNoLock")?;
Ok(())
}
/// Calls the openDAQ C function `daqPropertyObjectInternal_setProtectedPropertyValueNoLock()`.
pub fn set_protected_property_value_no_lock(&self, name: &str, value: impl Into<Value>) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectInternal_setProtectedPropertyValueNoLock)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqPropertyObjectInternal_setProtectedPropertyValueNoLock")?;
Ok(())
}
}
impl PropertyObjectProtected {
/// Clears a property value. Does not fail if the property is read-only.
///
/// # Parameters
/// - `property_name`: The name of the Property of which value the function should be cleared.
///
/// Calls the openDAQ C function `daqPropertyObjectProtected_clearProtectedPropertyValue()`.
pub fn clear_protected_property_value(&self, property_name: &str) -> Result<()> {
let __property_name = crate::marshal::make_string(property_name)?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectProtected_clearProtectedPropertyValue)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _) };
check(__code, "daqPropertyObjectProtected_clearProtectedPropertyValue")?;
Ok(())
}
/// Clears values of all properties contained in the Property object, including nested child properties.
/// This function behaves similarly to `IPropertyObject::clearPropertyValues()`, but also clears read-only properties.
///
/// Calls the openDAQ C function `daqPropertyObjectProtected_clearProtectedPropertyValues()`.
pub fn clear_protected_property_values(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObjectProtected_clearProtectedPropertyValues)(self.as_raw() as *mut _) };
check(__code, "daqPropertyObjectProtected_clearProtectedPropertyValues")?;
Ok(())
}
/// Sets a Selection property value by the selection item value. Does not fail if the property is read-only.
///
/// # Parameters
/// - `property_name`: The name of the Property.
/// - `value`: The selection value to set (must be one of the Property's selection values).
///
/// Calls the openDAQ C function `daqPropertyObjectProtected_setProtectedPropertySelectionValue()`.
pub fn set_protected_property_selection_value(&self, property_name: &str, value: impl Into<Value>) -> Result<()> {
let __property_name = crate::marshal::make_string(property_name)?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectProtected_setProtectedPropertySelectionValue)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqPropertyObjectProtected_setProtectedPropertySelectionValue")?;
Ok(())
}
/// Sets a property value. Does not fail if the property is read-only.
///
/// # Parameters
/// - `property_name`: The name of the Property of which value the function should set.
/// - `value`: The property value to set.
///
/// Calls the openDAQ C function `daqPropertyObjectProtected_setProtectedPropertyValue()`.
pub fn set_protected_property_value(&self, property_name: &str, value: impl Into<Value>) -> Result<()> {
let __property_name = crate::marshal::make_string(property_name)?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyObjectProtected_setProtectedPropertyValue)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqPropertyObjectProtected_setProtectedPropertyValue")?;
Ok(())
}
}
impl PropertyObject {
/// Adds the property to the Property object.
///
/// # Parameters
/// - `property`: The property to be added.
///
/// # Errors
/// - `OPENDAQ_ERR_INVALIDVALUE`: if the property has no name.
/// - `OPENDAQ_ERR_ALREADYEXISTS`: if a property with the same name is already part of the Property object.
/// - `OPENDAQ_ERR_FROZEN`: if the Property object is frozen. The Property is frozen once added to the Property object, making it immutable. The same Property cannot be added to multiple different Property objects.
///
/// Calls the openDAQ C function `daqPropertyObject_addProperty()`.
pub fn add_property(&self, property: &Property) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObject_addProperty)(self.as_raw() as *mut _, property.as_raw() as *mut _) };
check(__code, "daqPropertyObject_addProperty")?;
Ok(())
}
/// Begins batch configuration of the object.
/// Batched configuration is used to apply several settings at once. To begin batch configuration, call `beginUpdate`.
/// When the `setPropertyValue` is called on the object, the changes are not immediately applied to it. When `endUpdate`
/// is called, the property values set between the `beginUpdate` and `endUpdate` method calls are
/// applied. It triggers the ˙OnPropertyWriteEvent` for each property value set, and the `OnEndUpdate` event.
/// `beginUpdate` is called recursively for each child property object.
///
/// Calls the openDAQ C function `daqPropertyObject_beginUpdate()`.
pub fn begin_update(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObject_beginUpdate)(self.as_raw() as *mut _) };
check(__code, "daqPropertyObject_beginUpdate")?;
Ok(())
}
/// Clears the Property value from the Property object
///
/// # Parameters
/// - `property_name`: The name of the Property of which value should be cleared.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if a Property with given `propertyName` is not part of the Property object.
/// - `OPENDAQ_ERR_FROZEN`: if the Property object is frozen. When a Property value is set, the value is written in the internal dictionary of Property values. This function will remove said value from the dictionary. If the tries to obtain the Property value of a property that does not have a set Property value, then the default value is returned. Importantly, clearing the value of an Object-type property will call `clear` on all the child object's properties.
///
/// Calls the openDAQ C function `daqPropertyObject_clearPropertyValue()`.
pub fn clear_property_value(&self, property_name: &str) -> Result<()> {
let __property_name = crate::marshal::make_string(property_name)?;
let __code = unsafe { (crate::sys::api().daqPropertyObject_clearPropertyValue)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _) };
check(__code, "daqPropertyObject_clearPropertyValue")?;
Ok(())
}
/// Clears values of all properties contained in the Property object, including nested child properties.
/// This function clears the values by internally invoking `clearPropertyValue(...)` for all properties returned by
/// `getAllProperties()`; for object-type properties it therefore clears their child properties as well.
/// Read-only properties and frozen objects are skipped.
///
/// Calls the openDAQ C function `daqPropertyObject_clearPropertyValues()`.
pub fn clear_property_values(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObject_clearPropertyValues)(self.as_raw() as *mut _) };
check(__code, "daqPropertyObject_clearPropertyValues")?;
Ok(())
}
/// Creates a empty Property object with no class.
///
/// Calls the openDAQ C function `daqPropertyObject_createPropertyObject()`.
pub fn new() -> Result<PropertyObject> {
let mut __obj: *mut sys::daqPropertyObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_createPropertyObject)(&mut __obj) };
check(__code, "daqPropertyObject_createPropertyObject")?;
Ok(unsafe { crate::marshal::require_object::<PropertyObject>(__obj as *mut _, "daqPropertyObject_createPropertyObject") }?)
}
/// Creates a Property object that inherits the properties of a class added to the Type manager with the specified name.
///
/// # Parameters
/// - `manager`: The Type manager manager.
/// - `class_name`: The name of the class from which the Property object inherits its properties.
///
/// Calls the openDAQ C function `daqPropertyObject_createPropertyObjectWithClassAndManager()`.
pub fn with_class_and_manager(manager: &TypeManager, class_name: &str) -> Result<PropertyObject> {
let __class_name = crate::marshal::make_string(class_name)?;
let mut __obj: *mut sys::daqPropertyObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_createPropertyObjectWithClassAndManager)(&mut __obj, manager.as_raw() as *mut _, __class_name.as_ptr() as *mut _) };
check(__code, "daqPropertyObject_createPropertyObjectWithClassAndManager")?;
Ok(unsafe { crate::marshal::require_object::<PropertyObject>(__obj as *mut _, "daqPropertyObject_createPropertyObjectWithClassAndManager") }?)
}
/// Ends batch configuration of the object.
/// Batched configuration is used to apply several settings at once. To begin batch configuration, call `beginUpdate`.
/// When the `setPropertyValue` is called on the object, the changes are not immediately applied to it. When `endUpdate`
/// is called, the property values set between the `beginUpdate` and `endUpdate` method calls are
/// applied. It triggers the ˙OnPropertyWriteEvent` for each property value set, and the `OnEndUpdate` event.
/// `endUpdate` is called recursively for each child property object.
///
/// Calls the openDAQ C function `daqPropertyObject_endUpdate()`.
pub fn end_update(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPropertyObject_endUpdate)(self.as_raw() as *mut _) };
check(__code, "daqPropertyObject_endUpdate")?;
Ok(())
}
/// Retrieves a list of properties from the Property object that match the given property filter.
///
/// # Parameters
/// - `property_filter`: A filter used to select relevant properties. Can include a recursive wrapper to search thru nested property objects.
/// - `component_filter`: An optional filter to determine which components' properties are included in the search. A recursive wrapper can be used to enable tree-traversal search.
///
/// # Returns
/// - `properties`: The list containing the matching properties. If the propertyFilter is nullptr, only the visible properties directly associated with the current object are retrieved. When searching for properties within a component, if no componentFilter is provided, only the current component is searched. If a componentFilter is provided but the current component does not match it, the result will be an empty list.
///
/// Calls the openDAQ C function `daqPropertyObject_findProperties()`.
pub fn find_properties(&self, property_filter: &SearchFilter) -> Result<Vec<Property>> {
let mut __properties: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_findProperties)(self.as_raw() as *mut _, &mut __properties, property_filter.as_raw() as *mut _, std::ptr::null_mut()) };
check(__code, "daqPropertyObject_findProperties")?;
Ok(unsafe { crate::marshal::take_list::<Property>(__properties as *mut _, "daqPropertyObject_findProperties") }?)
}
/// Retrieves a list of properties from the Property object that match the given property filter.
///
/// # Parameters
/// - `property_filter`: A filter used to select relevant properties. Can include a recursive wrapper to search thru nested property objects.
/// - `component_filter`: An optional filter to determine which components' properties are included in the search. A recursive wrapper can be used to enable tree-traversal search.
///
/// # Returns
/// - `properties`: The list containing the matching properties. If the propertyFilter is nullptr, only the visible properties directly associated with the current object are retrieved. When searching for properties within a component, if no componentFilter is provided, only the current component is searched. If a componentFilter is provided but the current component does not match it, the result will be an empty list.
///
/// Calls the openDAQ C function `daqPropertyObject_findProperties()`.
pub fn find_properties_with(&self, property_filter: &SearchFilter, component_filter: Option<&SearchFilter>) -> Result<Vec<Property>> {
let mut __properties: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_findProperties)(self.as_raw() as *mut _, &mut __properties, property_filter.as_raw() as *mut _, component_filter.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _)) };
check(__code, "daqPropertyObject_findProperties")?;
Ok(unsafe { crate::marshal::take_list::<Property>(__properties as *mut _, "daqPropertyObject_findProperties") }?)
}
/// Returns a list of all properties contained in the Property object.
///
/// # Returns
/// - `properties`: The List of properties. Properties are retrieved regardless of their visibility. They are sorted in insertion order unless a custom order is specified. This function returns both the properties added to the Property object, as well as those of its class.
///
/// Calls the openDAQ C function `daqPropertyObject_getAllProperties()`.
pub fn all_properties(&self) -> Result<Vec<Property>> {
let mut __properties: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getAllProperties)(self.as_raw() as *mut _, &mut __properties) };
check(__code, "daqPropertyObject_getAllProperties")?;
Ok(unsafe { crate::marshal::take_list::<Property>(__properties as *mut _, "daqPropertyObject_getAllProperties") }?)
}
/// Gets the name of the class the Property object was constructed with.
///
/// # Returns
/// - `class_name`: The class's name. Contains an empty string if the class name is not configured. A Property object inherits all properties of the Property object class of the same name. Such Property objects have access to the Type manager from which they can retrieve its class type and its properties.
///
/// Calls the openDAQ C function `daqPropertyObject_getClassName()`.
pub fn class_name(&self) -> Result<String> {
let mut __class_name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getClassName)(self.as_raw() as *mut _, &mut __class_name) };
check(__code, "daqPropertyObject_getClassName")?;
Ok(unsafe { crate::marshal::take_string(__class_name) })
}
/// Gets the Event that is triggered whenever any Property value is read.The event is triggered after the specific Property event.
///
/// # Returns
/// - `event`: The read Event. A handler can be added to the event containing a callback function which is invoked whenever the event is triggered. The callback function requires two parameters - a Property object, as well as a "Property value event args" object. The callback will be invoked with the Property object holding the read value as the first argument. The second argument holds an event args object that contains the read Property value, event type (Read), and a method of overriding the read value. If the read value is overridden, the overridden value is read instead.
///
/// Calls the openDAQ C function `daqPropertyObject_getOnAnyPropertyValueRead()`.
pub fn on_any_property_value_read(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getOnAnyPropertyValueRead)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyObject_getOnAnyPropertyValueRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the Event that is triggered whenever any Property value is written. The event is triggered after the specific Property event.
///
/// # Returns
/// - `event`: The write Event. A handler can be added to the event containing a callback function which is invoked whenever the event is triggered. The callback function requires two parameters - a Property object, as well as a "Property value event args" object. The callback will be invoked with the Property object holding the written-to property as the first argument The second argument holds an event args object that contains the written value, event type (Update), and a method of overriding the written value. If the written value is overridden, the overridden value is stored in the Property object instead.
///
/// Calls the openDAQ C function `daqPropertyObject_getOnAnyPropertyValueWrite()`.
pub fn on_any_property_value_write(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getOnAnyPropertyValueWrite)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyObject_getOnAnyPropertyValueWrite")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the Event that is triggered whenever the batch configuration is applied.
///
/// # Returns
/// - `event`: The Event. A handler can be added to the event containing a callback function which is invoked whenever the event is triggered. The callback function requires one parameter - a "End update value event args" object. The callback will be invoked with the batch configuration is applied, i.e. from the `endUpdate` method. The first argument holds an event args object that contains a list of properties updated.
///
/// Calls the openDAQ C function `daqPropertyObject_getOnEndUpdate()`.
pub fn on_end_update(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getOnEndUpdate)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqPropertyObject_getOnEndUpdate")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the Event that is triggered whenever a Property value of a Property named `propertyName` is read.
///
/// # Parameters
/// - `property_name`: The name of the property.
///
/// # Returns
/// - `event`: The read Event.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if the Property object does not contain a Property named `propertyName`. A handler can be added to the event containing a callback function which is invoked whenever the event is triggered. The callback function requires two parameters - a Property object, as well as a "Property value event args" object. The callback will be invoked with the Property object holding the read value as the first argument. The second argument holds an event args object that contains the read Property value, event type (Read), and a method of overriding the read value. If the read value is overridden, the overridden value is read instead.
///
/// Calls the openDAQ C function `daqPropertyObject_getOnPropertyValueRead()`.
pub fn on_property_value_read(&self, property_name: &str) -> Result<Option<Event>> {
let __property_name = crate::marshal::make_string(property_name)?;
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getOnPropertyValueRead)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, &mut __event) };
check(__code, "daqPropertyObject_getOnPropertyValueRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the Event that is triggered whenever a Property value is written to the Property named `propertyName`.
///
/// # Parameters
/// - `property_name`: The name of the property.
///
/// # Returns
/// - `event`: The write Event.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if the Property object does not contain a Property named `propertyName`. A handler can be added to the event containing a callback function which is invoked whenever the event is triggered. The callback function requires two parameters - a Property object, as well as a "Property value event args" object. The callback will be invoked with the Property object holding the written-to property as the first argument The second argument holds an event args object that contains the written value, event type (Update), and a method of overriding the written value. If the written value is overridden, the overridden value is stored in the Property object instead.
///
/// Calls the openDAQ C function `daqPropertyObject_getOnPropertyValueWrite()`.
pub fn on_property_value_write(&self, property_name: &str) -> Result<Option<Event>> {
let __property_name = crate::marshal::make_string(property_name)?;
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getOnPropertyValueWrite)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, &mut __event) };
check(__code, "daqPropertyObject_getOnPropertyValueWrite")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the permission manager of property object.
///
/// # Returns
/// - `permission_manager`: The permission manager of property object.
///
/// Calls the openDAQ C function `daqPropertyObject_getPermissionManager()`.
pub fn permission_manager(&self) -> Result<Option<PermissionManager>> {
let mut __permission_manager: *mut sys::daqPermissionManager = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getPermissionManager)(self.as_raw() as *mut _, &mut __permission_manager) };
check(__code, "daqPropertyObject_getPermissionManager")?;
Ok(unsafe { crate::marshal::take_object::<PermissionManager>(__permission_manager as *mut _) })
}
/// Gets the Property with the given `propertyName`.
///
/// # Parameters
/// - `property_name`: The name of the property.
///
/// # Returns
/// - `property`: The retrieved Property.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if the Property object does not contain the requested Property. The property is obtained from either the Property object class of the Property object, or the object's local list of properties. The Property held by the object/class is not returned directly, but is instead cloned, and bound to the Property object. This allows for evaluation of Property metadata that depends on other properties of the Property object. For example, a Property's visibility might depend on the value of another Property. To make evaluation of the visibility parameter possible, the Property must be able to access its owning Property object. Likewise, Reference properties always point at another Property of a Property object. Again, for this to be possible, the Property must be able to access its owning Property object, to be able to retrieve its referenced Property.
///
/// Calls the openDAQ C function `daqPropertyObject_getProperty()`.
pub fn property(&self, property_name: &str) -> Result<Option<Property>> {
let __property_name = crate::marshal::make_string(property_name)?;
let mut __property: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getProperty)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, &mut __property) };
check(__code, "daqPropertyObject_getProperty")?;
Ok(unsafe { crate::marshal::take_object::<Property>(__property as *mut _) })
}
/// Gets the selected value of the Property, if the Property is a Selection property.
///
/// # Parameters
/// - `property_name`: The name of the Property.
///
/// # Returns
/// - `value`: The selected value.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if a Property with given `propertyName` is not part of the Property object.
/// - `OPENDAQ_ERR_INVALIDPROPERTY`: if the Property either has no Selection values, or the Selection values are not a list or dictionary.
/// - `OPENDAQ_ERR_INVALIDTYPE`: if the retrieved value does not match the Property's item type. This function serves as a shortcut to obtaining the Property value of a Property, and using it to retrieve the currently selected value from the Selection values of the Property. For example, if the Selection values contain the following list "\["banana", "apple", "pear"\]", and the corresponding Property value is set to 1, retrieving the Property selection value will return the string "apple".
///
/// Calls the openDAQ C function `daqPropertyObject_getPropertySelectionValue()`.
pub fn property_selection_value(&self, property_name: &str) -> Result<Value> {
let __property_name = crate::marshal::make_string(property_name)?;
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getPropertySelectionValue)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, &mut __value) };
check(__code, "daqPropertyObject_getPropertySelectionValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyObject_getPropertySelectionValue") }?)
}
/// Gets the value of the Property with the given name.
///
/// # Parameters
/// - `property_name`: The name of the Property.
///
/// # Returns
/// - `value`: The returned Property value.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if a property with given `propertyName` is not part of the Property object.
/// - `OPENDAQ_ERR_INVALIDPARAMETER`: if attempting to get a value at an index of a non-list Property.
/// - `OPENDAQ_ERR_OUTOFRANGE`: if attempting to get a value of a list Property at an out-of-bounds index. The value is retrieved from a local dictionary of Property values where they are stored when set. If a value is not present under the `propertyName` key, the default value of the corresponding Property is returned. If said property is not part of the Property object, an error occurs. @subsection value_get_child_property_objects Child Property objects The Property value getter allows for direct retrieval of values of child Property objects. To get the Property value of a child Property object, the `propertyName` parameter should be of the format: "childName.propertyName". This pattern can also be used to access nested properties - for example "childName1.childName2.childName3.propertyName". @subsection value_get_list_properties List properties If the requested Property is a list-type object, an item of the list at a selected index can be retrieved instead of the list itself. To do so, add a \[index\] suffix to the `propertyName` parameter. For example "ListProperty\[1\]" retrieves the 2nd item stored in the list Property value of the Property named "ListProperty". @subsection value_get_selection_properties Selection properties If the requested Property has the Selection values fields configured, the Property value getter returns an index/key of the selected item in the Selection values list/dictionary.
///
/// Calls the openDAQ C function `daqPropertyObject_getPropertyValue()`.
pub fn property_value(&self, property_name: &str) -> Result<Value> {
let __property_name = crate::marshal::make_string(property_name)?;
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getPropertyValue)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, &mut __value) };
check(__code, "daqPropertyObject_getPropertyValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyObject_getPropertyValue") }?)
}
/// Returns the state of batch configuration.
///
/// # Returns
/// - `updating`: True if the object is performing batch update of its properties. Batched configuration is used to apply several settings at once. To begin batch configuration, call `beginUpdate`. When the `setPropertyValue` is called on the object, the changes are not immediately applied. When `endUpdate` is called, the property values set between the `beginUpdate` and `endUpdate` method calls are applied. This method returns True if `beginUpdate` method has been called on the object` and `endUpdate` has not been called yet.
///
/// Calls the openDAQ C function `daqPropertyObject_getUpdating()`.
pub fn updating(&self) -> Result<bool> {
let mut __updating: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyObject_getUpdating)(self.as_raw() as *mut _, &mut __updating) };
check(__code, "daqPropertyObject_getUpdating")?;
Ok(__updating != 0)
}
/// Returns a list of visible properties contained in the Property object.
///
/// # Returns
/// - `properties`: The List of properties. A Property is visible if both the Visible parameter is set to `true`, and IsReferenced is `false`. The properties are sorted in insertion order unless a custom order is specified. This function returns both the properties added to the Property object, as well as those of its class.
///
/// Calls the openDAQ C function `daqPropertyObject_getVisibleProperties()`.
pub fn visible_properties(&self) -> Result<Vec<Property>> {
let mut __properties: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyObject_getVisibleProperties)(self.as_raw() as *mut _, &mut __properties) };
check(__code, "daqPropertyObject_getVisibleProperties")?;
Ok(unsafe { crate::marshal::take_list::<Property>(__properties as *mut _, "daqPropertyObject_getVisibleProperties") }?)
}
/// Checks if the Property object contains a property named `propertyName`.
///
/// # Parameters
/// - `property_name`: The name of the property.
///
/// # Returns
/// - `has_property`: True if the Property object contains the Property; false otherwise.
///
/// Calls the openDAQ C function `daqPropertyObject_hasProperty()`.
pub fn has_property(&self, property_name: &str) -> Result<bool> {
let __property_name = crate::marshal::make_string(property_name)?;
let mut __has_property: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyObject_hasProperty)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, &mut __has_property) };
check(__code, "daqPropertyObject_hasProperty")?;
Ok(__has_property != 0)
}
/// Removes the Property named `propertyName` from the Property object.
///
/// # Parameters
/// - `property_name`: The name of the Property to be removed.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if the Property object does not contain a Property named `propertyName`, or the Property is part of the Property object's Property object class.
/// - `OPENDAQ_ERR_FROZEN`: if the Property object is frozen. A property can only be removed from a Property object, if it was added to the object, and not inherited from its class.
///
/// Calls the openDAQ C function `daqPropertyObject_removeProperty()`.
pub fn remove_property(&self, property_name: &str) -> Result<()> {
let __property_name = crate::marshal::make_string(property_name)?;
let __code = unsafe { (crate::sys::api().daqPropertyObject_removeProperty)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _) };
check(__code, "daqPropertyObject_removeProperty")?;
Ok(())
}
/// Sets a custom order of properties as defined in the list of property names.
///
/// # Parameters
/// - `ordered_property_names`: A list of names of properties. The order of the list is applied to the object's properties.
///
/// # Errors
/// - `OPENDAQ_ERR_FROZEN`: if the Property object is frozen. The list should contain names of properties available in the object. When retrieving the Property object's properties, they will be sorted in the order in which the names appear in the provided list. Any properties not in the custom order are kept in insertion order at the end of the Property object's list of properties.
///
/// Calls the openDAQ C function `daqPropertyObject_setPropertyOrder()`.
pub fn set_property_order(&self, ordered_property_names: &[&str]) -> Result<()> {
let __ordered_property_names = crate::marshal::list_from_strs(ordered_property_names)?;
let __code = unsafe { (crate::sys::api().daqPropertyObject_setPropertyOrder)(self.as_raw() as *mut _, __ordered_property_names.as_ptr() as *mut _) };
check(__code, "daqPropertyObject_setPropertyOrder")?;
Ok(())
}
/// Sets the value of a Selection property by the selection item value (e.g. string, float, or list/dict value).
///
/// # Parameters
/// - `property_name`: The name of the Property.
/// - `value`: The selection value to set (must be one of the Property's selection values). Cannot be null.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if a Property with given `propertyName` is not part of the Property object, or the value is not in the selection.
/// - `OPENDAQ_ERR_INVALIDPROPERTY`: if the Property has no Selection values.
/// - `OPENDAQ_ERR_ACCESSDENIED`: if the property is Read-only.
/// - `OPENDAQ_ERR_FROZEN`: if the Property object is frozen. Works for all Selection properties (list or dictionary): the value is the actual selection item (e.g. a string from the list, or the value part of a key-value pair in the dictionary). Use setPropertyValue when setting by index/key.
///
/// Calls the openDAQ C function `daqPropertyObject_setPropertySelectionValue()`.
pub fn set_property_selection_value(&self, property_name: &str, value: impl Into<Value>) -> Result<()> {
let __property_name = crate::marshal::make_string(property_name)?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyObject_setPropertySelectionValue)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqPropertyObject_setPropertySelectionValue")?;
Ok(())
}
/// Sets the value of the Property with the given name.
///
/// # Parameters
/// - `property_name`: The name of the Property.
/// - `value`: The Property value to be set. Cannot be null.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if a property with given `propertyName` is not part of the Property object.
/// - `OPENDAQ_ERR_ACCESSDENIED`: if the property is Read-only.
/// - `OPENDAQ_ERR_CONVERSIONFAILED`: if the `value` cannot be converted to the Value type of the Property.
/// - `OPENDAQ_ERR_INVALIDTYPE`: if the `value` is a list/dictionary/object with invalid keys/items/fields.
/// - `OPENDAQ_ERR_VALIDATE_FAILED`: if the Validator fails to validate the `value`.
/// - `OPENDAQ_ERR_COERCION_FAILED`: if the Coercer fails to coerce the `value`.
/// - `OPENDAQ_ERR_FROZEN`: if the Property object is frozen.
/// - `OPENDAQ_ERR_IGNORED`: if the `value` is the same as the default, or the previously written value. Stores the provided `value` into an internal dictionary of property name and value pairs. This property value can later be retrieved through the corresponding getter method when invoked with the same `propertyName`. The provided `value` must adhere to the restrictions of the corresponding Property (that bears the name `propertyName`). If such a Property is part of the Property object, the setter call will fail. Some restrictions include: - The core type of the value must match that of the Property Value type. - If the Property is a numeric type, the value must be equal or greater than the Min value, and equal or smaller than the Max value. - If the Property is Read-only, the setter will fail. - The value will be validated by the Property validator causing the setter method to fail if validation is unsuccessful. - The value will be coerced to fit the coercion expression of the Property coercer before being written into the local dictionary of property values. Setting the value of a Property will override either its default value or the value that was set beforehand. @subsection patterns Behaviour patterns of note - When setting the value of a Property with the Selection values field configured (a Selection property), the `value` must be an integer type, and acts as an index/key into the list/dictionary of Selection values. - If the Property is a Reference property (the Referenced property field is configured), the `value` is actually written under the key of the referenced Property, not the one specified through the `propertyName` argument. - When setting a list or dictionary type property, the list items and dictionary keys and items must be homogeneous, and of the same type as specified by the item and key type of the Property. - Setting a Property value will invoke the corresponding `onPropertyValueWrite` event. @subsection value_set_child_property_objects Child Property objects The Property value setter allows for direct configuration of any child Property objects. To set the Property value of a child Property object, the `propertyName` parameter should be of the format: "childName.propertyName". This pattern can also be used to access nested properties - for example "childName1.childName2.childName3.propertyName".
///
/// Calls the openDAQ C function `daqPropertyObject_setPropertyValue()`.
pub fn set_property_value(&self, property_name: &str, value: impl Into<Value>) -> Result<()> {
let __property_name = crate::marshal::make_string(property_name)?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyObject_setPropertyValue)(self.as_raw() as *mut _, __property_name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqPropertyObject_setPropertyValue")?;
Ok(())
}
}
impl PropertyValueEventArgs {
/// Calls the openDAQ C function `daqPropertyValueEventArgs_createPropertyValueEventArgs()`.
pub fn new(prop: &Property, value: impl Into<Value>, old_value: impl Into<Value>, type_: PropertyEventType, is_updating: bool) -> Result<PropertyValueEventArgs> {
let __value = crate::value::to_daq(&value.into())?;
let __old_value = crate::value::to_daq(&old_value.into())?;
let mut __obj: *mut sys::daqPropertyValueEventArgs = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyValueEventArgs_createPropertyValueEventArgs)(&mut __obj, prop.as_raw() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _, crate::value::opt_ref_ptr(&__old_value) as *mut _, type_ as u32, u8::from(is_updating)) };
check(__code, "daqPropertyValueEventArgs_createPropertyValueEventArgs")?;
Ok(unsafe { crate::marshal::require_object::<PropertyValueEventArgs>(__obj as *mut _, "daqPropertyValueEventArgs_createPropertyValueEventArgs") }?)
}
/// Calls the openDAQ C function `daqPropertyValueEventArgs_getIsUpdating()`.
pub fn is_updating(&self) -> Result<bool> {
let mut __is_updating: u8 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyValueEventArgs_getIsUpdating)(self.as_raw() as *mut _, &mut __is_updating) };
check(__code, "daqPropertyValueEventArgs_getIsUpdating")?;
Ok(__is_updating != 0)
}
/// Calls the openDAQ C function `daqPropertyValueEventArgs_getOldValue()`.
pub fn old_value(&self) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyValueEventArgs_getOldValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqPropertyValueEventArgs_getOldValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyValueEventArgs_getOldValue") }?)
}
/// Calls the openDAQ C function `daqPropertyValueEventArgs_getProperty()`.
pub fn property(&self) -> Result<Option<Property>> {
let mut __property: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyValueEventArgs_getProperty)(self.as_raw() as *mut _, &mut __property) };
check(__code, "daqPropertyValueEventArgs_getProperty")?;
Ok(unsafe { crate::marshal::take_object::<Property>(__property as *mut _) })
}
/// Calls the openDAQ C function `daqPropertyValueEventArgs_getPropertyEventType()`.
pub fn property_event_type(&self) -> Result<PropertyEventType> {
let mut __change_type: u32 = 0;
let __code = unsafe { (crate::sys::api().daqPropertyValueEventArgs_getPropertyEventType)(self.as_raw() as *mut _, &mut __change_type) };
check(__code, "daqPropertyValueEventArgs_getPropertyEventType")?;
Ok(crate::marshal::enum_out(PropertyEventType::from_raw(__change_type), "daqPropertyValueEventArgs_getPropertyEventType")?)
}
/// Calls the openDAQ C function `daqPropertyValueEventArgs_getValue()`.
pub fn value(&self) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqPropertyValueEventArgs_getValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqPropertyValueEventArgs_getValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqPropertyValueEventArgs_getValue") }?)
}
/// Calls the openDAQ C function `daqPropertyValueEventArgs_setValue()`.
pub fn set_value(&self, value: impl Into<Value>) -> Result<()> {
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqPropertyValueEventArgs_setValue)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqPropertyValueEventArgs_setValue")?;
Ok(())
}
}
impl Property {
/// Creates a boolean Property object with a default value and Visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The boolean default value. Can be an EvalValue.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctBool`. Note that the defaultValue and visible parameters can be EvalValues.
///
/// Calls the openDAQ C function `daqProperty_createBoolProperty()`.
pub fn bool(name: &str, default_value: bool, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::bool_to_ref(default_value)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createBoolProperty)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createBoolProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createBoolProperty") }?)
}
/// Creates a dictionary Property object with a default value and Visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The dictionary default value.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctDict`. The visible parameter can be an EvalValue. The dictionary passed as default value must have homogeneous key and value lists. The Property's Item type field will be set according to defaultValue dictionary Item type. The same goes for the Key type. TODO: defaultValue can be an EvalValue once dictionaries are supported.
///
/// Calls the openDAQ C function `daqProperty_createDictProperty()`.
pub fn dict(name: &str, default_value: impl Into<Value>, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::to_daq(&default_value.into())?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createDictProperty)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__default_value) as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createDictProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createDictProperty") }?)
}
/// Creates an Enumeration Property object with a default value and its visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The default structure value.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctEnumeration`.
///
/// Calls the openDAQ C function `daqProperty_createEnumerationProperty()`.
pub fn enumeration(name: &str, default_value: &Enumeration, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createEnumerationProperty)(&mut __obj, __name.as_ptr() as *mut _, default_value.as_raw() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createEnumerationProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createEnumerationProperty") }?)
}
/// Creates a floating point value Property object with a default value and Visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The float default value. Can be an EvalValue.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctFloat`. Note that the defaultValue and visible parameters can be EvalValues.
///
/// Calls the openDAQ C function `daqProperty_createFloatProperty()`.
pub fn float(name: &str, default_value: f64, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::float_to_ref(default_value)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createFloatProperty)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createFloatProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createFloatProperty") }?)
}
/// Creates a function- or procedure-type Property object. Requires the a CallableInfo object to specify the argument type/count and function return type.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `callable_info`: Information about the callable argument type/count and return type.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctFunction` or `ctProc`, depending on if `callableInfo` contains information on the return type or not. Note that the visible parameter can be an EvalValue.
///
/// Calls the openDAQ C function `daqProperty_createFunctionProperty()`.
pub fn function(name: &str, callable_info: &CallableInfo, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createFunctionProperty)(&mut __obj, __name.as_ptr() as *mut _, callable_info.as_raw() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createFunctionProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createFunctionProperty") }?)
}
/// Creates an integer Property object with a default value and Visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The integer default value. Can be an EvalValue.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctInt`. Note that the defaultValue and visible parameters can be EvalValues.
///
/// Calls the openDAQ C function `daqProperty_createIntProperty()`.
pub fn int(name: &str, default_value: i64, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::int_to_ref(default_value)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createIntProperty)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createIntProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createIntProperty") }?)
}
/// Creates a list Property object with a default value and Visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The list default value. Can be an EvalValue.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctList`. Note that the defaultValue and visible parameters can be EvalValues. The list passed as `defaultValue` must be homogeneous. The Property's Item type field will be set according to defaultValue list type.
///
/// Calls the openDAQ C function `daqProperty_createListProperty()`.
pub fn list(name: &str, default_value: impl Into<Value>, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::to_daq(&default_value.into())?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createListProperty)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__default_value) as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createListProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createListProperty") }?)
}
/// Creates an object-type Property object with a default value and optional Visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The Property object default value. The Property Value type is `ctObject`. Object properties cannot be have any metadata other than their name, description, and default value configured. The PropertyObject default value can only be a base PropertyObject type (not a descendant type). If the defaultValue is not specified, it will automatically be configured to an empty Property Object.
///
/// Calls the openDAQ C function `daqProperty_createObjectProperty()`.
pub fn object(name: &str, default_value: &PropertyObject) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createObjectProperty)(&mut __obj, __name.as_ptr() as *mut _, default_value.as_raw() as *mut _) };
check(__code, "daqProperty_createObjectProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createObjectProperty") }?)
}
/// Creates a ratio Property object with a default value and Visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The ratio default value.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctRatio`. Note that the visible parameter can be an EvalValue. TODO: defaultValue can be an EvalValue once ratios are supported.
///
/// Calls the openDAQ C function `daqProperty_createRatioProperty()`.
pub fn ratio(name: &str, default_value: Ratio, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::value::ratio_to_ref(default_value)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createRatioProperty)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createRatioProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createRatioProperty") }?)
}
/// Creates a Reference Property object that points at a property specified in the `referencedProperty` parameter.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `referenced_property_eval`: The evaluation expression that evaluates to another property.
///
/// Calls the openDAQ C function `daqProperty_createReferenceProperty()`.
pub fn reference(name: &str, referenced_property_eval: &EvalValue) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createReferenceProperty)(&mut __obj, __name.as_ptr() as *mut _, referenced_property_eval.as_raw() as *mut _) };
check(__code, "daqProperty_createReferenceProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createReferenceProperty") }?)
}
/// Creates a Selection Property object with a list of selection values. The default value is an integer index into the default selected value.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `selection_values`: The list of selectable values.
/// - `default_value`: The default index into the list of selection values.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctInt`.
///
/// Calls the openDAQ C function `daqProperty_createSelectionProperty()`.
pub fn selection(name: &str, selection_values: impl Into<Value>, default_value: i64, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __selection_values = crate::value::to_daq(&selection_values.into())?;
let __default_value = crate::value::int_to_ref(default_value)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createSelectionProperty)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__selection_values) as *mut _, __default_value.as_ptr() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createSelectionProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createSelectionProperty") }?)
}
/// Creates a Selection Property object with a dictionary of selection values. The default value is an integer key into the provided dictionary.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `selection_values`: The dictionary of selectable values. The key type must be `ctInt`.
/// - `default_value`: The default key into the list of selection values.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctInt`. The key type of the Selection values dictionary must be `ctInt`.
///
/// Calls the openDAQ C function `daqProperty_createSparseSelectionProperty()`.
pub fn sparse_selection(name: &str, selection_values: impl Into<Value>, default_value: i64, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __selection_values = crate::value::to_daq(&selection_values.into())?;
let __default_value = crate::value::int_to_ref(default_value)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createSparseSelectionProperty)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__selection_values) as *mut _, __default_value.as_ptr() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createSparseSelectionProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createSparseSelectionProperty") }?)
}
/// Creates a string Property object with a default value and Visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The integer default value. Can be an EvalValue.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctString`. Note that the defaultValue and visible parameters can be EvalValues.
///
/// Calls the openDAQ C function `daqProperty_createStringProperty()`.
pub fn string(name: &str, default_value: &str, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __default_value = crate::marshal::make_string(default_value)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createStringProperty)(&mut __obj, __name.as_ptr() as *mut _, __default_value.as_ptr() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createStringProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createStringProperty") }?)
}
/// Creates a Struct Property object with a default value and its visible state.
///
/// # Parameters
/// - `name`: The name of the Property.
/// - `default_value`: The default structure value.
/// - `visible`: If true, the Property is visible. Can be an EvalValue. The Property Value type is `ctStruct`.
///
/// Calls the openDAQ C function `daqProperty_createStructProperty()`.
pub fn struct_(name: &str, default_value: &Struct, visible: bool) -> Result<Property> {
let __name = crate::marshal::make_string(name)?;
let __visible = crate::value::bool_to_ref(visible)?;
let mut __obj: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_createStructProperty)(&mut __obj, __name.as_ptr() as *mut _, default_value.as_raw() as *mut _, __visible.as_ptr() as *mut _) };
check(__code, "daqProperty_createStructProperty")?;
Ok(unsafe { crate::marshal::require_object::<Property>(__obj as *mut _, "daqProperty_createStructProperty") }?)
}
/// Gets the Callable information objects of the Property that specifies the argument and return types of the callable object stored as the Property value.
///
/// # Returns
/// - `callable`: The Callable info object.
///
/// Calls the openDAQ C function `daqProperty_getCallableInfo()`.
pub fn callable_info(&self) -> Result<Option<CallableInfo>> {
let mut __callable: *mut sys::daqCallableInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getCallableInfo)(self.as_raw() as *mut _, &mut __callable) };
check(__code, "daqProperty_getCallableInfo")?;
Ok(unsafe { crate::marshal::take_object::<CallableInfo>(__callable as *mut _) })
}
/// Gets the coercer of the Property.
///
/// # Returns
/// - `coercer`: The coercer. Used to coerce a value written to the corresponding Property value to the constraints specified by the coercer.
///
/// Calls the openDAQ C function `daqProperty_getCoercer()`.
pub fn coercer(&self) -> Result<Option<Coercer>> {
let mut __coercer: *mut sys::daqCoercer = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getCoercer)(self.as_raw() as *mut _, &mut __coercer) };
check(__code, "daqProperty_getCoercer")?;
Ok(unsafe { crate::marshal::take_object::<Coercer>(__coercer as *mut _) })
}
/// Gets the Default value of the Property. The Default value must always be configured for a Property to be in a valid state. Exceptions are Function/Procedure and Reference properties.
///
/// # Returns
/// - `value`: The Default value of the Property.
///
/// Calls the openDAQ C function `daqProperty_getDefaultValue()`.
pub fn default_value(&self) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getDefaultValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqProperty_getDefaultValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqProperty_getDefaultValue") }?)
}
/// Gets the short string Description of the Property.
///
/// # Returns
/// - `description`: The Description of the Property.
///
/// Calls the openDAQ C function `daqProperty_getDescription()`.
pub fn description(&self) -> Result<String> {
let mut __description: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getDescription)(self.as_raw() as *mut _, &mut __description) };
check(__code, "daqProperty_getDescription")?;
Ok(unsafe { crate::marshal::take_string(__description) })
}
/// Used to determine whether the Property is referenced by another property.
///
/// # Returns
/// - `is_referenced`: True if the Property is referenced by another property; false otherwise.
///
/// Calls the openDAQ C function `daqProperty_getIsReferenced()`.
pub fn is_referenced(&self) -> Result<bool> {
let mut __is_referenced: u8 = 0;
let __code = unsafe { (crate::sys::api().daqProperty_getIsReferenced)(self.as_raw() as *mut _, &mut __is_referenced) };
check(__code, "daqProperty_getIsReferenced")?;
Ok(__is_referenced != 0)
}
/// Gets the Item type of the Property. Configured only if the Value type is `ctDict` or `ctList`. If so, the item types of the list/dictionary must match the Property's Item type.
///
/// # Returns
/// - `type`: The Item type of list/dictionary properties.
///
/// Calls the openDAQ C function `daqProperty_getItemType()`.
pub fn item_type(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqProperty_getItemType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqProperty_getItemType")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqProperty_getItemType")?)
}
/// Gets the Key type of the Property. Configured only if the Value type is `ctDict`. If so, the key type of the dictionary Property values must match the Property's Key type.
///
/// # Returns
/// - `type`: The Key type of dictionary properties.
///
/// Calls the openDAQ C function `daqProperty_getKeyType()`.
pub fn key_type(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqProperty_getKeyType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqProperty_getKeyType")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqProperty_getKeyType")?)
}
/// Gets the Maximum value of the Property. Available only if the Value type is `ctInt` or `ctFloat`.
///
/// # Returns
/// - `max`: The Maximum value of the Property.
///
/// Calls the openDAQ C function `daqProperty_getMaxValue()`.
pub fn max_value(&self) -> Result<Option<f64>> {
let mut __max: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getMaxValue)(self.as_raw() as *mut _, &mut __max) };
check(__code, "daqProperty_getMaxValue")?;
Ok(unsafe { crate::value::take_number(__max, "daqProperty_getMaxValue") }?)
}
/// Gets the Minimum value of the Property. Available only if the Value type is `ctInt` or `ctFloat`.
///
/// # Returns
/// - `min`: The Minimum value of the Property.
///
/// Calls the openDAQ C function `daqProperty_getMinValue()`.
pub fn min_value(&self) -> Result<Option<f64>> {
let mut __min: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getMinValue)(self.as_raw() as *mut _, &mut __min) };
check(__code, "daqProperty_getMinValue")?;
Ok(unsafe { crate::value::take_number(__min, "daqProperty_getMinValue") }?)
}
/// Gets the Name of the Property. The names of Properties in a Property object must be unique. The name is used as the key to the corresponding Property value when getting/setting the value.
///
/// # Returns
/// - `name`: The Name of the Property.
///
/// Calls the openDAQ C function `daqProperty_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqProperty_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets the event object that is triggered when the corresponding Property value is read.
///
/// # Returns
/// - `event`: The On-read event. The event arguments contain a reference to the property object, as well as a function allowing for the read value to be overridden.
///
/// Calls the openDAQ C function `daqProperty_getOnPropertyValueRead()`.
pub fn on_property_value_read(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getOnPropertyValueRead)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqProperty_getOnPropertyValueRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the event object that is triggered when a value is written to the corresponding Property value.
///
/// # Returns
/// - `event`: The On-write event. The event arguments contain a reference to the property object, as well as a function allowing for the written value to be overridden.
///
/// Calls the openDAQ C function `daqProperty_getOnPropertyValueWrite()`.
pub fn on_property_value_write(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getOnPropertyValueWrite)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqProperty_getOnPropertyValueWrite")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the event triggered when a user retrieves the selection values field. Allows for overriding the returned value.
///
/// # Returns
/// - `event`: The `onRead` event triggered when suggested values are read. There should at any point be a single listener that overrides the returned value. Any listeners are expected to always configure the returned value via the Property metadata read arguments object.
///
/// Calls the openDAQ C function `daqProperty_getOnSelectionValuesRead()`.
pub fn on_selection_values_read(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getOnSelectionValuesRead)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqProperty_getOnSelectionValuesRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the event triggered when a user retrieves the suggested values field. Allows for overriding the returned value.
///
/// # Returns
/// - `event`: The `onRead` event triggered when suggested values are read. There should at any point be a single listener that overrides the returned value. Any listeners are expected to always configure the returned value via the Property metadata read arguments object.
///
/// Calls the openDAQ C function `daqProperty_getOnSuggestedValuesRead()`.
pub fn on_suggested_values_read(&self) -> Result<Option<Event>> {
let mut __event: *mut sys::daqEvent = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getOnSuggestedValuesRead)(self.as_raw() as *mut _, &mut __event) };
check(__code, "daqProperty_getOnSuggestedValuesRead")?;
Ok(unsafe { crate::marshal::take_object::<Event>(__event as *mut _) })
}
/// Gets the type of the Property.
///
/// # Returns
/// - `type`: The type of the Property. The type of the Property is a combination of the CoreType and the additional property types.
///
/// Calls the openDAQ C function `daqProperty_getPropertyType()`.
pub fn property_type(&self) -> Result<PropertyType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqProperty_getPropertyType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqProperty_getPropertyType")?;
Ok(crate::marshal::enum_out(PropertyType::from_raw(__type_), "daqProperty_getPropertyType")?)
}
/// Used to determine whether the Property is a read-only property or not.
///
/// # Returns
/// - `read_only`: True if the Property is a read-only property; false otherwise. Read-only Property values can still be modified by using the `PropertyObjectProtected` interface methods.
///
/// Calls the openDAQ C function `daqProperty_getReadOnly()`.
pub fn read_only(&self) -> Result<bool> {
let mut __read_only: u8 = 0;
let __code = unsafe { (crate::sys::api().daqProperty_getReadOnly)(self.as_raw() as *mut _, &mut __read_only) };
check(__code, "daqProperty_getReadOnly")?;
Ok(__read_only != 0)
}
/// Gets the referenced property. If set, all getters except for the `Name`, `Referenced property`, and `Is referenced` getters will return the value of the `Referenced property`.
///
/// # Returns
/// - `property`: The referenced property. If the Property is not bound to a Property object this call will not be able to return the Referenced property.
///
/// Calls the openDAQ C function `daqProperty_getReferencedProperty()`.
pub fn referenced_property(&self) -> Result<Option<Property>> {
let mut __property: *mut sys::daqProperty = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getReferencedProperty)(self.as_raw() as *mut _, &mut __property) };
check(__code, "daqProperty_getReferencedProperty")?;
Ok(unsafe { crate::marshal::take_object::<Property>(__property as *mut _) })
}
/// Gets the list or dictionary of selection values. If the list/dictionary is not empty, the property is a Selection property, and must have the Value type `ctInt`.
///
/// # Returns
/// - `values`: The list/dictionary of possible selection values.
///
/// Calls the openDAQ C function `daqProperty_getSelectionValues()`.
pub fn selection_values(&self) -> Result<Value> {
let mut __values: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getSelectionValues)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqProperty_getSelectionValues")?;
Ok(unsafe { crate::value::take_value(__values, "daqProperty_getSelectionValues") }?)
}
/// Gets the Struct type object of the Property, if the Property is a Struct property.
///
/// # Returns
/// - `struct_type`: The Struct type of the Struct Property.
///
/// Calls the openDAQ C function `daqProperty_getStructType()`.
pub fn struct_type(&self) -> Result<Option<StructType>> {
let mut __struct_type: *mut sys::daqStructType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getStructType)(self.as_raw() as *mut _, &mut __struct_type) };
check(__code, "daqProperty_getStructType")?;
Ok(unsafe { crate::marshal::take_object::<StructType>(__struct_type as *mut _) })
}
/// Gets the list of Suggested values. Contains values that are the optimal settings for the corresponding Property value. These values, however, are not enforced when setting a new Property value.
///
/// # Returns
/// - `values`: The Suggested values of the Property. Only numerical and string-type properties can have suggested values.
///
/// Calls the openDAQ C function `daqProperty_getSuggestedValues()`.
pub fn suggested_values(&self) -> Result<Vec<Value>> {
let mut __values: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getSuggestedValues)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqProperty_getSuggestedValues")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__values as *mut _, "daqProperty_getSuggestedValues") }?)
}
/// Gets the Unit of the Property.
///
/// # Returns
/// - `unit`: The Unit of the Property.
///
/// Calls the openDAQ C function `daqProperty_getUnit()`.
pub fn unit(&self) -> Result<Option<Unit>> {
let mut __unit: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getUnit)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqProperty_getUnit")?;
Ok(unsafe { crate::marshal::take_object::<Unit>(__unit as *mut _) })
}
/// Gets the validator of the Property.
///
/// # Returns
/// - `validator`: The validator. Used to validate whether a value written to the corresponding Property value is valid or not.
///
/// Calls the openDAQ C function `daqProperty_getValidator()`.
pub fn validator(&self) -> Result<Option<Validator>> {
let mut __validator: *mut sys::daqValidator = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getValidator)(self.as_raw() as *mut _, &mut __validator) };
check(__code, "daqProperty_getValidator")?;
Ok(unsafe { crate::marshal::take_object::<Validator>(__validator as *mut _) })
}
/// Gets the value of the Property. Available only if the Property is bound to a Property object.
///
/// # Parameters
/// - `value`: The Property value.
///
/// # Returns
/// OPENDAQ_ERR_NO_OWNER if the Property is not bound to a Property object. The call is equivalent to calling `getPropertyValue` on the Property object and all the limitations and implications of that call still apply.
///
/// Calls the openDAQ C function `daqProperty_getValue()`.
pub fn value(&self) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqProperty_getValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqProperty_getValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqProperty_getValue") }?)
}
/// Gets the Value type of the Property. Values written to the corresponding Property value must be of the same type.
///
/// # Returns
/// - `type`: The value type.
///
/// Calls the openDAQ C function `daqProperty_getValueType()`.
pub fn value_type(&self) -> Result<CoreType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqProperty_getValueType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqProperty_getValueType")?;
Ok(crate::marshal::enum_out(CoreType::from_raw(__type_), "daqProperty_getValueType")?)
}
/// Used to determine whether the property is visible or not.
///
/// # Returns
/// - `visible`: True if the Property is visible; false otherwise.
///
/// Calls the openDAQ C function `daqProperty_getVisible()`.
pub fn visible(&self) -> Result<bool> {
let mut __visible: u8 = 0;
let __code = unsafe { (crate::sys::api().daqProperty_getVisible)(self.as_raw() as *mut _, &mut __visible) };
check(__code, "daqProperty_getVisible")?;
Ok(__visible != 0)
}
/// Sets the value of the Property. Available only if the Property is bound to a Property object.
///
/// # Parameters
/// - `value`: The Property value.
///
/// # Returns
/// OPENDAQ_ERR_NO_OWNER if the Property is not bound to a Property object. The call is equivalent to calling `getPropertyValue` on the Property object and all the limitations and implications of that call still apply.
///
/// Calls the openDAQ C function `daqProperty_setValue()`.
pub fn set_value(&self, value: impl Into<Value>) -> Result<()> {
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqProperty_setValue)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqProperty_setValue")?;
Ok(())
}
}
impl RatioObject {
/// Calls the openDAQ C function `daqRatio_createRatio()`.
pub fn new(numerator: i64, denominator: i64) -> Result<RatioObject> {
let mut __obj: *mut sys::daqRatio = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqRatio_createRatio)(&mut __obj, numerator, denominator) };
check(__code, "daqRatio_createRatio")?;
Ok(unsafe { crate::marshal::require_object::<RatioObject>(__obj as *mut _, "daqRatio_createRatio") }?)
}
/// Gets denominator part.
///
/// # Returns
/// - `denominator`: Denominator value.
///
/// Calls the openDAQ C function `daqRatio_getDenominator()`.
pub fn denominator(&self) -> Result<i64> {
let mut __denominator: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqRatio_getDenominator)(self.as_raw() as *mut _, &mut __denominator) };
check(__code, "daqRatio_getDenominator")?;
Ok(__denominator)
}
/// Gets numerator part.
///
/// # Returns
/// - `numerator`: Numerator value.
///
/// Calls the openDAQ C function `daqRatio_getNumerator()`.
pub fn numerator(&self) -> Result<i64> {
let mut __numerator: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqRatio_getNumerator)(self.as_raw() as *mut _, &mut __numerator) };
check(__code, "daqRatio_getNumerator")?;
Ok(__numerator)
}
/// Simplifies rational number if possible and returns the simplified ratio as a new object.
///
/// # Returns
/// - `simplified_ratio`: the simplified ratio. Call this method to reduce stored rational number to the lowest terms possible. Example: 10/100 is reduced to 1/10.
///
/// Calls the openDAQ C function `daqRatio_simplify()`.
pub fn simplify(&self) -> Result<Option<Ratio>> {
let mut __simplified_ratio: *mut sys::daqRatio = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqRatio_simplify)(self.as_raw() as *mut _, &mut __simplified_ratio) };
check(__code, "daqRatio_simplify")?;
Ok(unsafe { crate::value::take_ratio(__simplified_ratio, "daqRatio_simplify") }?)
}
}
impl SearchFilter {
/// Defines whether or not the object should be included in the search results
///
/// # Parameters
/// - `obj`: The object being evaluated.
///
/// # Returns
/// - `accepts`: True of the object is to be included in the results; false otherwise.
///
/// Calls the openDAQ C function `daqSearchFilter_acceptsObject()`.
pub fn accepts_object(&self, obj: impl Into<Value>) -> Result<bool> {
let __obj = crate::value::to_daq(&obj.into())?;
let mut __accepts: u8 = 0;
let __code = unsafe { (crate::sys::api().daqSearchFilter_acceptsObject)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__obj) as *mut _, &mut __accepts) };
check(__code, "daqSearchFilter_acceptsObject")?;
Ok(__accepts != 0)
}
/// Creates a "conjunction" search filter that combines 2 filters, accepting an object only if both filters accept it. "Visit children" returns `true` only if both filters do so.
///
/// # Parameters
/// - `left`: The first argument of the conjunction operation.
/// - `right`: The second argument of the conjunction operation.
///
/// Calls the openDAQ C function `daqSearchFilter_createAndSearchFilter()`.
pub fn and(left: &SearchFilter, right: &SearchFilter) -> Result<SearchFilter> {
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createAndSearchFilter)(&mut __obj, left.as_raw() as *mut _, right.as_raw() as *mut _) };
check(__code, "daqSearchFilter_createAndSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createAndSearchFilter") }?)
}
/// Creates a search filter that accepts all objects. "Visit children" always returns `true`.
///
/// Calls the openDAQ C function `daqSearchFilter_createAnySearchFilter()`.
pub fn any() -> Result<SearchFilter> {
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createAnySearchFilter)(&mut __obj) };
check(__code, "daqSearchFilter_createAnySearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createAnySearchFilter") }?)
}
/// Creates a custom search filter with a user-defined "accepts object" and "visit children" function.
///
/// # Parameters
/// - `accepts_function`: The function to be called when "accepts object" is called. Should return `true` or `false`.
/// - `visit_function`: The function to be called when "visit children" is called. Should return `true` or `false`.
///
/// Calls the openDAQ C function `daqSearchFilter_createCustomSearchFilter()`.
pub fn custom(accepts_function: &FunctionObject, visit_function: &FunctionObject) -> Result<SearchFilter> {
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createCustomSearchFilter)(&mut __obj, accepts_function.as_raw() as *mut _, visit_function.as_raw() as *mut _) };
check(__code, "daqSearchFilter_createCustomSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createCustomSearchFilter") }?)
}
/// Calls the openDAQ C function `daqSearchFilter_createExcludedTagsSearchFilter()`.
pub fn excluded_tags(excluded_tags: impl Into<Value>) -> Result<SearchFilter> {
let __excluded_tags = crate::value::to_daq(&excluded_tags.into())?;
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createExcludedTagsSearchFilter)(&mut __obj, crate::value::opt_ref_ptr(&__excluded_tags) as *mut _) };
check(__code, "daqSearchFilter_createExcludedTagsSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createExcludedTagsSearchFilter") }?)
}
/// Calls the openDAQ C function `daqSearchFilter_createInterfaceIdSearchFilter()`.
pub fn interface_id(intf_id: crate::IntfID) -> Result<SearchFilter> {
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createInterfaceIdSearchFilter)(&mut __obj, intf_id) };
check(__code, "daqSearchFilter_createInterfaceIdSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createInterfaceIdSearchFilter") }?)
}
/// Calls the openDAQ C function `daqSearchFilter_createLocalIdSearchFilter()`.
pub fn local_id(local_id: &str) -> Result<SearchFilter> {
let __local_id = crate::marshal::make_string(local_id)?;
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createLocalIdSearchFilter)(&mut __obj, __local_id.as_ptr() as *mut _) };
check(__code, "daqSearchFilter_createLocalIdSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createLocalIdSearchFilter") }?)
}
/// Creates a search filter that negates the "accepts object" result of the filter provided as construction argument. Does not negate the "visit children" result.
///
/// # Parameters
/// - `filter`: The filter of which results should be negated.
///
/// Calls the openDAQ C function `daqSearchFilter_createNotSearchFilter()`.
pub fn not(filter: &SearchFilter) -> Result<SearchFilter> {
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createNotSearchFilter)(&mut __obj, filter.as_raw() as *mut _) };
check(__code, "daqSearchFilter_createNotSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createNotSearchFilter") }?)
}
/// Creates a "disjunction" search filter that combines 2 filters, accepting an object if any of the two filters accepts it. "Visit children" returns `true` if any of the two filters accepts does so.
///
/// # Parameters
/// - `left`: The first argument of the disjunction operation.
/// - `right`: The second argument of the disjunction operation.
///
/// Calls the openDAQ C function `daqSearchFilter_createOrSearchFilter()`.
pub fn or(left: &SearchFilter, right: &SearchFilter) -> Result<SearchFilter> {
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createOrSearchFilter)(&mut __obj, left.as_raw() as *mut _, right.as_raw() as *mut _) };
check(__code, "daqSearchFilter_createOrSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createOrSearchFilter") }?)
}
/// Creates a search filter that indicates that the search method should recursively search through the object's child elements. This filter constructor should always be the final filter wrapper, and should not be used as a constructor argument for another filter.
///
/// # Parameters
/// - `filter`: The filter to be wrapped with a "recursive" flag.
///
/// Calls the openDAQ C function `daqSearchFilter_createRecursiveSearchFilter()`.
pub fn recursive(filter: &SearchFilter) -> Result<SearchFilter> {
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createRecursiveSearchFilter)(&mut __obj, filter.as_raw() as *mut _) };
check(__code, "daqSearchFilter_createRecursiveSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createRecursiveSearchFilter") }?)
}
/// Calls the openDAQ C function `daqSearchFilter_createRequiredTagsSearchFilter()`.
pub fn required_tags(required_tags: impl Into<Value>) -> Result<SearchFilter> {
let __required_tags = crate::value::to_daq(&required_tags.into())?;
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createRequiredTagsSearchFilter)(&mut __obj, crate::value::opt_ref_ptr(&__required_tags) as *mut _) };
check(__code, "daqSearchFilter_createRequiredTagsSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createRequiredTagsSearchFilter") }?)
}
/// Calls the openDAQ C function `daqSearchFilter_createVisibleSearchFilter()`.
pub fn visible() -> Result<SearchFilter> {
let mut __obj: *mut sys::daqSearchFilter = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSearchFilter_createVisibleSearchFilter)(&mut __obj) };
check(__code, "daqSearchFilter_createVisibleSearchFilter")?;
Ok(unsafe { crate::marshal::require_object::<SearchFilter>(__obj as *mut _, "daqSearchFilter_createVisibleSearchFilter") }?)
}
/// Defines whether or not the children of said object should be traversed during a recursive search.
///
/// # Parameters
/// - `obj`: The object being evaluated.
///
/// # Returns
/// - `visit`: True of the object's children should be traversed; false otherwise.
///
/// Calls the openDAQ C function `daqSearchFilter_visitChildren()`.
pub fn visit_children(&self, obj: impl Into<Value>) -> Result<bool> {
let __obj = crate::value::to_daq(&obj.into())?;
let mut __visit: u8 = 0;
let __code = unsafe { (crate::sys::api().daqSearchFilter_visitChildren)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__obj) as *mut _, &mut __visit) };
check(__code, "daqSearchFilter_visitChildren")?;
Ok(__visit != 0)
}
}
impl StringObject {
/// Calls the openDAQ C function `daqString_createString()`.
pub fn new(str: &str) -> Result<StringObject> {
let __str = crate::marshal::make_c_string(str)?;
let mut __obj: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqString_createString)(&mut __obj, __str.as_ptr() as _) };
check(__code, "daqString_createString")?;
Ok(unsafe { crate::marshal::require_object::<StringObject>(__obj as *mut _, "daqString_createString") }?)
}
/// Calls the openDAQ C function `daqString_createStringN()`.
pub fn n(str: &str, length: usize) -> Result<StringObject> {
let __str = crate::marshal::make_c_string(str)?;
let mut __obj: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqString_createStringN)(&mut __obj, __str.as_ptr() as _, length) };
check(__code, "daqString_createStringN")?;
Ok(unsafe { crate::marshal::require_object::<StringObject>(__obj as *mut _, "daqString_createStringN") }?)
}
/// Gets a string value stored in the object.
///
/// # Returns
/// OPENDAQ_SUCCESS if succeeded, error code otherwise. Call this method to extract the string value that is stored in the object. Method extracts the value as a pointer to 8-bit char type.
/// - `value`: Stored string value.
///
/// Calls the openDAQ C function `daqString_getCharPtr()`.
pub fn char_ptr(&self) -> Result<String> {
let mut __value: *const c_char = std::ptr::null();
let __code = unsafe { (crate::sys::api().daqString_getCharPtr)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqString_getCharPtr")?;
Ok(unsafe { crate::marshal::copy_const_char_ptr(__value) })
}
/// Gets length of string.
///
/// # Returns
/// OPENDAQ_SUCCESS if succeeded, error code otherwise. Call this method to get the length of the string. Null char terminator is not included in the size of the string.
/// - `size`: The size of the string.
///
/// Calls the openDAQ C function `daqString_getLength()`.
pub fn length(&self) -> Result<usize> {
let mut __size: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqString_getLength)(self.as_raw() as *mut _, &mut __size) };
check(__code, "daqString_getLength")?;
Ok(__size)
}
}
impl StructType {
/// Calls the openDAQ C function `daqStructType_createStructType()`.
pub fn new(name: &str, names: impl Into<Value>, default_values: impl Into<Value>, types: impl Into<Value>) -> Result<StructType> {
let __name = crate::marshal::make_string(name)?;
let __names = crate::value::to_daq(&names.into())?;
let __default_values = crate::value::to_daq(&default_values.into())?;
let __types = crate::value::to_daq(&types.into())?;
let mut __obj: *mut sys::daqStructType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStructType_createStructType)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__names) as *mut _, crate::value::opt_ref_ptr(&__default_values) as *mut _, crate::value::opt_ref_ptr(&__types) as *mut _) };
check(__code, "daqStructType_createStructType")?;
Ok(unsafe { crate::marshal::require_object::<StructType>(__obj as *mut _, "daqStructType_createStructType") }?)
}
/// Calls the openDAQ C function `daqStructType_createStructTypeNoDefaults()`.
pub fn no_defaults(name: &str, names: impl Into<Value>, types: impl Into<Value>) -> Result<StructType> {
let __name = crate::marshal::make_string(name)?;
let __names = crate::value::to_daq(&names.into())?;
let __types = crate::value::to_daq(&types.into())?;
let mut __obj: *mut sys::daqStructType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStructType_createStructTypeNoDefaults)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__names) as *mut _, crate::value::opt_ref_ptr(&__types) as *mut _) };
check(__code, "daqStructType_createStructTypeNoDefaults")?;
Ok(unsafe { crate::marshal::require_object::<StructType>(__obj as *mut _, "daqStructType_createStructTypeNoDefaults") }?)
}
/// Gets the list of field default values.
///
/// # Returns
/// - `default_values`: The list of field default values (Base objects)
///
/// Calls the openDAQ C function `daqStructType_getFieldDefaultValues()`.
pub fn field_default_values(&self) -> Result<Vec<Value>> {
let mut __default_values: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStructType_getFieldDefaultValues)(self.as_raw() as *mut _, &mut __default_values) };
check(__code, "daqStructType_getFieldDefaultValues")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__default_values as *mut _, "daqStructType_getFieldDefaultValues") }?)
}
/// Gets the list of field names.
///
/// # Returns
/// - `names`: The list of field names (String objects)
///
/// Calls the openDAQ C function `daqStructType_getFieldNames()`.
pub fn field_names(&self) -> Result<Vec<String>> {
let mut __names: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStructType_getFieldNames)(self.as_raw() as *mut _, &mut __names) };
check(__code, "daqStructType_getFieldNames")?;
Ok(unsafe { crate::marshal::take_list::<String>(__names as *mut _, "daqStructType_getFieldNames") }?)
}
/// Gets the list of field types.
///
/// # Returns
/// - `types`: The list of field types (Type objects)
///
/// Calls the openDAQ C function `daqStructType_getFieldTypes()`.
pub fn field_types(&self) -> Result<Vec<Type>> {
let mut __types: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStructType_getFieldTypes)(self.as_raw() as *mut _, &mut __types) };
check(__code, "daqStructType_getFieldTypes")?;
Ok(unsafe { crate::marshal::take_list::<Type>(__types as *mut _, "daqStructType_getFieldTypes") }?)
}
}
impl Struct {
/// Calls the openDAQ C function `daqStruct_createStruct()`.
pub fn new(name: &str, fields: impl Into<Value>, type_manager: &TypeManager) -> Result<Struct> {
let __name = crate::marshal::make_string(name)?;
let __fields = crate::value::to_daq(&fields.into())?;
let mut __obj: *mut sys::daqStruct = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStruct_createStruct)(&mut __obj, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__fields) as *mut _, type_manager.as_raw() as *mut _) };
check(__code, "daqStruct_createStruct")?;
Ok(unsafe { crate::marshal::require_object::<Struct>(__obj as *mut _, "daqStruct_createStruct") }?)
}
/// Calls the openDAQ C function `daqStruct_createStructFromBuilder()`.
pub fn from_builder(builder: &StructBuilder) -> Result<Struct> {
let mut __obj: *mut sys::daqStruct = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStruct_createStructFromBuilder)(&mut __obj, builder.as_raw() as *mut _) };
check(__code, "daqStruct_createStructFromBuilder")?;
Ok(unsafe { crate::marshal::require_object::<Struct>(__obj as *mut _, "daqStruct_createStructFromBuilder") }?)
}
/// Gets the value of a field with the given name.
///
/// # Parameters
/// - `name`: The name of the queried field.
///
/// # Returns
/// - `field`: The value of the field.
///
/// Calls the openDAQ C function `daqStruct_get()`.
pub fn get(&self, name: &str) -> Result<Value> {
let __name = crate::marshal::make_string(name)?;
let mut __field: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStruct_get)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, &mut __field) };
check(__code, "daqStruct_get")?;
Ok(unsafe { crate::value::take_value(__field, "daqStruct_get") }?)
}
/// Gets the field names and values of the Struct as a Dictionary.
///
/// # Returns
/// - `dictionary`: The Dictionary object with field names as keys, and field values as its values.
///
/// Calls the openDAQ C function `daqStruct_getAsDictionary()`.
pub fn as_dictionary(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __dictionary: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStruct_getAsDictionary)(self.as_raw() as *mut _, &mut __dictionary) };
check(__code, "daqStruct_getAsDictionary")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__dictionary as *mut _, "daqStruct_getAsDictionary") }?)
}
/// Gets a list of all Struct field names.
///
/// # Returns
/// - `names`: The list of field names. The list of names will be of equal length to the list of values. Additionally, the name of a field at any given index corresponds to the value stored in the list of values.
///
/// Calls the openDAQ C function `daqStruct_getFieldNames()`.
pub fn field_names(&self) -> Result<Vec<String>> {
let mut __names: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStruct_getFieldNames)(self.as_raw() as *mut _, &mut __names) };
check(__code, "daqStruct_getFieldNames")?;
Ok(unsafe { crate::marshal::take_list::<String>(__names as *mut _, "daqStruct_getFieldNames") }?)
}
/// Gets a list of all Struct field values.
///
/// # Returns
/// - `values`: The list of field values. The list of names will be of equal length to the list of values. Additionally, the name of a field at any given index corresponds to the value stored in the list of values.
///
/// Calls the openDAQ C function `daqStruct_getFieldValues()`.
pub fn field_values(&self) -> Result<Vec<Value>> {
let mut __values: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStruct_getFieldValues)(self.as_raw() as *mut _, &mut __values) };
check(__code, "daqStruct_getFieldValues")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__values as *mut _, "daqStruct_getFieldValues") }?)
}
/// Gets the Struct's type.
///
/// # Returns
/// - `type`: The Struct type
///
/// Calls the openDAQ C function `daqStruct_getStructType()`.
pub fn struct_type(&self) -> Result<Option<StructType>> {
let mut __type_: *mut sys::daqStructType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqStruct_getStructType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqStruct_getStructType")?;
Ok(unsafe { crate::marshal::take_object::<StructType>(__type_ as *mut _) })
}
/// Checks whether a field with the given name exists in the Struct
///
/// # Parameters
/// - `name`: The name of the checked field.
///
/// # Returns
/// - `contains`: True if the a field with `name` exists in the Struct; false otherwise.
///
/// Calls the openDAQ C function `daqStruct_hasField()`.
pub fn has_field(&self, name: &str) -> Result<bool> {
let __name = crate::marshal::make_string(name)?;
let mut __contains: u8 = 0;
let __code = unsafe { (crate::sys::api().daqStruct_hasField)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, &mut __contains) };
check(__code, "daqStruct_hasField")?;
Ok(__contains != 0)
}
}
impl TypeManager {
/// Adds a type to the manager.
///
/// # Parameters
/// - `type`: The Type to be added.
///
/// # Errors
/// - `OPENDAQ_ERR_ALREADYEXISTS`: if a type with the same name is already added.
/// - `OPENDAQ_ERR_INVALIDPARAMETER`: if either the type name is an empty string. The type name must be unique and. If a Property object class specifies a parent class, then the parent class must be added before it.
///
/// Calls the openDAQ C function `daqTypeManager_addType()`.
pub fn add_type(&self, type_: &Type) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqTypeManager_addType)(self.as_raw() as *mut _, type_.as_raw() as *mut _) };
check(__code, "daqTypeManager_addType")?;
Ok(())
}
/// Calls the openDAQ C function `daqTypeManager_createTypeManager()`.
pub fn new() -> Result<TypeManager> {
let mut __obj: *mut sys::daqTypeManager = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqTypeManager_createTypeManager)(&mut __obj) };
check(__code, "daqTypeManager_createTypeManager")?;
Ok(unsafe { crate::marshal::require_object::<TypeManager>(__obj as *mut _, "daqTypeManager_createTypeManager") }?)
}
/// Gets an added Type by name.
///
/// # Parameters
/// - `type_name`: The Type's name.
///
/// # Returns
/// - `type`: The Type with name equal to `name`.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if a Type with the specified name is not added.
///
/// Calls the openDAQ C function `daqTypeManager_getType()`.
pub fn type_(&self, type_name: &str) -> Result<Option<Type>> {
let __type_name = crate::marshal::make_string(type_name)?;
let mut __type_: *mut sys::daqType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqTypeManager_getType)(self.as_raw() as *mut _, __type_name.as_ptr() as *mut _, &mut __type_) };
check(__code, "daqTypeManager_getType")?;
Ok(unsafe { crate::marshal::take_object::<Type>(__type_ as *mut _) })
}
/// Gets a list of all added Types.
///
/// # Returns
/// - `types`: The list of all added Types.
///
/// Calls the openDAQ C function `daqTypeManager_getTypes()`.
pub fn types(&self) -> Result<Vec<String>> {
let mut __types: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqTypeManager_getTypes)(self.as_raw() as *mut _, &mut __types) };
check(__code, "daqTypeManager_getTypes")?;
Ok(unsafe { crate::marshal::take_list::<String>(__types as *mut _, "daqTypeManager_getTypes") }?)
}
/// Checks if a type with the specified name is already added.
///
/// # Parameters
/// - `type_name`: The name of the checked type.
///
/// # Returns
/// - `has_type`: True if the type is aready added to the manager; False otherwise.
///
/// Calls the openDAQ C function `daqTypeManager_hasType()`.
pub fn has_type(&self, type_name: &str) -> Result<bool> {
let __type_name = crate::marshal::make_string(type_name)?;
let mut __has_type: u8 = 0;
let __code = unsafe { (crate::sys::api().daqTypeManager_hasType)(self.as_raw() as *mut _, __type_name.as_ptr() as *mut _, &mut __has_type) };
check(__code, "daqTypeManager_hasType")?;
Ok(__has_type != 0)
}
/// Removes the type from the manager.
///
/// # Parameters
/// - `type_name`: The type's name.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if the class is not registered. The removed class must not be a parent of another added class. If it is, those classes must be removed before it.
///
/// Calls the openDAQ C function `daqTypeManager_removeType()`.
pub fn remove_type(&self, type_name: &str) -> Result<()> {
let __type_name = crate::marshal::make_string(type_name)?;
let __code = unsafe { (crate::sys::api().daqTypeManager_removeType)(self.as_raw() as *mut _, __type_name.as_ptr() as *mut _) };
check(__code, "daqTypeManager_removeType")?;
Ok(())
}
}
impl Type {
/// Gets the name of the Type
///
/// # Returns
/// - `type_name`: The name of the Type.
///
/// Calls the openDAQ C function `daqType_getName()`.
pub fn name(&self) -> Result<String> {
let mut __type_name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqType_getName)(self.as_raw() as *mut _, &mut __type_name) };
check(__code, "daqType_getName")?;
Ok(unsafe { crate::marshal::take_string(__type_name) })
}
}
impl UnitBuilder {
/// Builds and returns a Unit object using the currently set values of the Builder.
///
/// # Returns
/// - `unit`: The built Unit.
///
/// Calls the openDAQ C function `daqUnitBuilder_build()`.
pub fn build(&self) -> Result<Option<Unit>> {
let mut __unit: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnitBuilder_build)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqUnitBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<Unit>(__unit as *mut _) })
}
/// Creates a UnitConfig with no parameters configured.
///
/// Calls the openDAQ C function `daqUnitBuilder_createUnitBuilder()`.
pub fn new() -> Result<UnitBuilder> {
let mut __obj: *mut sys::daqUnitBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnitBuilder_createUnitBuilder)(&mut __obj) };
check(__code, "daqUnitBuilder_createUnitBuilder")?;
Ok(unsafe { crate::marshal::require_object::<UnitBuilder>(__obj as *mut _, "daqUnitBuilder_createUnitBuilder") }?)
}
/// UnitConfig copy factory that creates a configurable Unit object from a possibly non-configurable Unit.
///
/// # Parameters
/// - `unit_to_copy`: The Unit of which configuration should be copied.
///
/// Calls the openDAQ C function `daqUnitBuilder_createUnitBuilderFromExisting()`.
pub fn from_existing(unit_to_copy: &Unit) -> Result<UnitBuilder> {
let mut __obj: *mut sys::daqUnitBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnitBuilder_createUnitBuilderFromExisting)(&mut __obj, unit_to_copy.as_raw() as *mut _) };
check(__code, "daqUnitBuilder_createUnitBuilderFromExisting")?;
Ok(unsafe { crate::marshal::require_object::<UnitBuilder>(__obj as *mut _, "daqUnitBuilder_createUnitBuilderFromExisting") }?)
}
/// Gets the unit ID as defined in \<a href="https://unece.org/trade/cefact/UNLOCODE-Download"\>Codes for Units of Measurement used in International Trade\</a\>.
///
/// # Returns
/// - `id`: The unit ID. Returns -1 if the unit id is not available.
///
/// Calls the openDAQ C function `daqUnitBuilder_getId()`.
pub fn id(&self) -> Result<i64> {
let mut __id: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqUnitBuilder_getId)(self.as_raw() as *mut _, &mut __id) };
check(__code, "daqUnitBuilder_getId")?;
Ok(__id)
}
/// Gets the full name of the unit, i.e. "meters per second".
///
/// # Returns
/// - `name`: The unit's full name. `nullptr` if not set.
///
/// Calls the openDAQ C function `daqUnitBuilder_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnitBuilder_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqUnitBuilder_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets the quantity represented by the unit, i.e. "Velocity"
///
/// # Returns
/// - `quantity`: The unit's quantity. `nullptr` if not set.
///
/// Calls the openDAQ C function `daqUnitBuilder_getQuantity()`.
pub fn quantity(&self) -> Result<String> {
let mut __quantity: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnitBuilder_getQuantity)(self.as_raw() as *mut _, &mut __quantity) };
check(__code, "daqUnitBuilder_getQuantity")?;
Ok(unsafe { crate::marshal::take_string(__quantity) })
}
/// Gets the symbol of the unit, i.e. "m/s".
///
/// # Returns
/// - `symbol`: The unit's symbol.
///
/// Calls the openDAQ C function `daqUnitBuilder_getSymbol()`.
pub fn symbol(&self) -> Result<String> {
let mut __symbol: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnitBuilder_getSymbol)(self.as_raw() as *mut _, &mut __symbol) };
check(__code, "daqUnitBuilder_getSymbol")?;
Ok(unsafe { crate::marshal::take_string(__symbol) })
}
/// Sets the unit ID as defined in \<a href="https://unece.org/trade/cefact/UNLOCODE-Download"\>Codes for Units of Measurement used in International Trade\</a\>.
///
/// # Parameters
/// - `id`: The unit ID. The ID should be -1 if the unit is not available.
///
/// Calls the openDAQ C function `daqUnitBuilder_setId()`.
pub fn set_id(&self, id: i64) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqUnitBuilder_setId)(self.as_raw() as *mut _, id) };
check(__code, "daqUnitBuilder_setId")?;
Ok(())
}
/// Sets the full name of the unit, i.e. "meters per second".
///
/// # Parameters
/// - `name`: The unit's full name.
///
/// Calls the openDAQ C function `daqUnitBuilder_setName()`.
pub fn set_name(&self, name: &str) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __code = unsafe { (crate::sys::api().daqUnitBuilder_setName)(self.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqUnitBuilder_setName")?;
Ok(())
}
/// Sets the quantity represented by the unit, i.e. "Velocity"
///
/// # Parameters
/// - `quantity`: The unit's quantity.
///
/// Calls the openDAQ C function `daqUnitBuilder_setQuantity()`.
pub fn set_quantity(&self, quantity: &str) -> Result<()> {
let __quantity = crate::marshal::make_string(quantity)?;
let __code = unsafe { (crate::sys::api().daqUnitBuilder_setQuantity)(self.as_raw() as *mut _, __quantity.as_ptr() as *mut _) };
check(__code, "daqUnitBuilder_setQuantity")?;
Ok(())
}
/// Sets the symbol of the unit, i.e. "m/s".
///
/// # Parameters
/// - `symbol`: The unit's symbol.
///
/// Calls the openDAQ C function `daqUnitBuilder_setSymbol()`.
pub fn set_symbol(&self, symbol: &str) -> Result<()> {
let __symbol = crate::marshal::make_string(symbol)?;
let __code = unsafe { (crate::sys::api().daqUnitBuilder_setSymbol)(self.as_raw() as *mut _, __symbol.as_ptr() as *mut _) };
check(__code, "daqUnitBuilder_setSymbol")?;
Ok(())
}
}
impl Unit {
/// Creates a Unit struct with its `id`, `symbol`, `name`, and `quantity` fields configured.
///
/// # Parameters
/// - `id`: The unit ID as defined in \<a href="https://unece.org/trade/cefact/UNLOCODE-Download"\>Codes for Units of Measurement used in International Trade\</a\>.
/// - `symbol`: The symbol of the unit, i.e. "m/s".
/// - `name`: The full name of the unit, i.e. "meters per second". (optional)
/// - `quantity`: The quantity represented by the unit, i.e. "Velocity". (optional)
///
/// Calls the openDAQ C function `daqUnit_createUnit()`.
pub fn new(id: i64, symbol: &str, name: &str, quantity: &str) -> Result<Unit> {
let __symbol = crate::marshal::make_string(symbol)?;
let __name = crate::marshal::make_string(name)?;
let __quantity = crate::marshal::make_string(quantity)?;
let mut __obj: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnit_createUnit)(&mut __obj, id, __symbol.as_ptr() as *mut _, __name.as_ptr() as *mut _, __quantity.as_ptr() as *mut _) };
check(__code, "daqUnit_createUnit")?;
Ok(unsafe { crate::marshal::require_object::<Unit>(__obj as *mut _, "daqUnit_createUnit") }?)
}
/// Gets the unit ID as defined in \<a href="https://unece.org/trade/cefact/UNLOCODE-Download"\>Codes for Units of Measurement used in International Trade\</a\>.
///
/// # Returns
/// - `id`: The unit ID. Returns -1 if the unit id is not available.
///
/// Calls the openDAQ C function `daqUnit_getId()`.
pub fn id(&self) -> Result<i64> {
let mut __id: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqUnit_getId)(self.as_raw() as *mut _, &mut __id) };
check(__code, "daqUnit_getId")?;
Ok(__id)
}
/// Gets the full name of the unit, i.e. "meters per second".
///
/// # Returns
/// - `name`: The unit's full name. `nullptr` if not set.
///
/// Calls the openDAQ C function `daqUnit_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnit_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqUnit_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets the quantity represented by the unit, i.e. "Velocity"
///
/// # Returns
/// - `quantity`: The unit's quantity. `nullptr` if not set.
///
/// Calls the openDAQ C function `daqUnit_getQuantity()`.
pub fn quantity(&self) -> Result<String> {
let mut __quantity: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnit_getQuantity)(self.as_raw() as *mut _, &mut __quantity) };
check(__code, "daqUnit_getQuantity")?;
Ok(unsafe { crate::marshal::take_string(__quantity) })
}
/// Gets the symbol of the unit, i.e. "m/s".
///
/// # Returns
/// - `symbol`: The unit's symbol.
///
/// Calls the openDAQ C function `daqUnit_getSymbol()`.
pub fn symbol(&self) -> Result<String> {
let mut __symbol: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUnit_getSymbol)(self.as_raw() as *mut _, &mut __symbol) };
check(__code, "daqUnit_getSymbol")?;
Ok(unsafe { crate::marshal::take_string(__symbol) })
}
}
impl UserInternal {
/// Returns the user's password, which can either be in plain text or hashed using the Bcrypt algorithm. Hashed passwords should follow the Modular Crypt Format. For security purposes, hashed passwords are preferred.
///
/// # Parameters
/// - `password_hash`: \[out\] Returns the user's password, which can either be in plain text or hashed using the Bcrypt algorithm.
///
/// Calls the openDAQ C function `daqUserInternal_getPasswordHash()`.
pub fn password_hash(&self) -> Result<String> {
let mut __password_hash: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUserInternal_getPasswordHash)(self.as_raw() as *mut _, &mut __password_hash) };
check(__code, "daqUserInternal_getPasswordHash")?;
Ok(unsafe { crate::marshal::take_string(__password_hash) })
}
/// Returns true if user is anonymous. Anonymous user is any user without defined username and passowrd.
///
/// # Parameters
/// - `anonymous`: \[out\] Returns true if user is anonymous.
///
/// Calls the openDAQ C function `daqUserInternal_isAnonymous()`.
pub fn is_anonymous(&self) -> Result<bool> {
let mut __anonymous: u8 = 0;
let __code = unsafe { (crate::sys::api().daqUserInternal_isAnonymous)(self.as_raw() as *mut _, &mut __anonymous) };
check(__code, "daqUserInternal_isAnonymous")?;
Ok(__anonymous != 0)
}
}
impl User {
/// Creates an immutable user object
///
/// # Parameters
/// - `username`: The username.
/// - `password_hash`: The hashed password as a string in Modular Crypt Format.
/// - `groups`: The list of group IDs which the user belongs to.
///
/// Calls the openDAQ C function `daqUser_createUser()`.
pub fn new(username: &str, password_hash: &str, groups: impl Into<Value>) -> Result<User> {
let __username = crate::marshal::make_string(username)?;
let __password_hash = crate::marshal::make_string(password_hash)?;
let __groups = crate::value::to_daq(&groups.into())?;
let mut __obj: *mut sys::daqUser = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUser_createUser)(&mut __obj, __username.as_ptr() as *mut _, __password_hash.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__groups) as *mut _) };
check(__code, "daqUser_createUser")?;
Ok(unsafe { crate::marshal::require_object::<User>(__obj as *mut _, "daqUser_createUser") }?)
}
/// Returns a list of group IDs which the user belongs to.
///
/// # Parameters
/// - `password`: \[out\] groups The list of group IDs which the user belongs to.
///
/// Calls the openDAQ C function `daqUser_getGroups()`.
pub fn groups(&self) -> Result<Vec<String>> {
let mut __groups: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUser_getGroups)(self.as_raw() as *mut _, &mut __groups) };
check(__code, "daqUser_getGroups")?;
Ok(unsafe { crate::marshal::take_list::<String>(__groups as *mut _, "daqUser_getGroups") }?)
}
/// Returns the username as a string.
///
/// # Parameters
/// - `username`: \[out\] The username.
///
/// Calls the openDAQ C function `daqUser_getUsername()`.
pub fn username(&self) -> Result<String> {
let mut __username: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqUser_getUsername)(self.as_raw() as *mut _, &mut __username) };
check(__code, "daqUser_getUsername")?;
Ok(unsafe { crate::marshal::take_string(__username) })
}
}
impl Validator {
/// Creates a Validator with the given evaluation expression.
///
/// # Parameters
/// - `eval`: The evaluation expression used for validation.
///
/// Calls the openDAQ C function `daqValidator_createValidator()`.
pub fn new(eval: &str) -> Result<Validator> {
let __eval = crate::marshal::make_string(eval)?;
let mut __obj: *mut sys::daqValidator = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqValidator_createValidator)(&mut __obj, __eval.as_ptr() as *mut _) };
check(__code, "daqValidator_createValidator")?;
Ok(unsafe { crate::marshal::require_object::<Validator>(__obj as *mut _, "daqValidator_createValidator") }?)
}
/// Gets the string expression used when creating the validator.
///
/// # Returns
/// - `eval`: The validation expression.
///
/// Calls the openDAQ C function `daqValidator_getEval()`.
pub fn eval(&self) -> Result<String> {
let mut __eval: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqValidator_getEval)(self.as_raw() as *mut _, &mut __eval) };
check(__code, "daqValidator_getEval")?;
Ok(unsafe { crate::marshal::take_string(__eval) })
}
/// Checks whether `value` adheres to the validity conditions of the validator.
///
/// # Parameters
/// - `prop_obj`: Optional property object parameter required if the validation depends on other properties of the Property object.
/// - `value`: The value to be checked for whether it is valid or not.
///
/// # Errors
/// - `OPENDAQ_ERR_VALIDATE_FAILED`: if `value` is invalid.
/// - `OPENDAQ_SUCCESS`: if `value` is valid.
///
/// Calls the openDAQ C function `daqValidator_validate()`.
pub fn validate(&self, prop_obj: impl Into<Value>, value: impl Into<Value>) -> Result<()> {
let __prop_obj = crate::value::to_daq(&prop_obj.into())?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqValidator_validate)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__prop_obj) as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqValidator_validate")?;
Ok(())
}
/// Calls the openDAQ C function `daqValidator_validateNoLock()`.
pub fn validate_no_lock(&self, prop_obj: impl Into<Value>, value: impl Into<Value>) -> Result<()> {
let __prop_obj = crate::value::to_daq(&prop_obj.into())?;
let __value = crate::value::to_daq(&value.into())?;
let __code = unsafe { (crate::sys::api().daqValidator_validateNoLock)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__prop_obj) as *mut _, crate::value::opt_ref_ptr(&__value) as *mut _) };
check(__code, "daqValidator_validateNoLock")?;
Ok(())
}
}