tango_client/lib.rs
1//! A Rust binding to the Tango control system.
2//!
3//! This crate provides a client API for [Tango control system] servers.
4//! It uses the preexisting C bindings (included) and wraps the API functions
5//! provided by it in a Rustic interface.
6//!
7//! [Tango control system]: https://tango-controls.org/
8//!
9//! Example usage:
10//!
11//! ```
12//! use tango_client::{DeviceProxy, CommandData};
13//!
14//! let mut dev = DeviceProxy::new("sys/tg_test/1")?;
15//! let argin = CommandData::from_str("Test");
16//! let argout = dev.command_inout("DevString", arg)?;
17//! assert_eq!(argout.into_bytes().unwrap(), "Test".as_bytes());
18//! ```
19//!
20//! At present, only the most used subset of Database and Device APIs are
21//! wrapped. Only synchronous calls are implemented.
22
23// For leak checking:
24// use std::alloc::System;
25// #[global_allocator]
26// static ALLOCATOR: System = System;
27
28#[doc(hidden)]
29pub use tango_client_sys as c;
30
31
32macro_rules! tango_call {
33 ($call:ident, $res:expr, $($args:expr),+) => {
34 {
35 let error_stack = unsafe {
36 c::$call($($args,)+)
37 };
38 if !error_stack.is_null() {
39 Err(TangoError::from_stack(error_stack))
40 } else {
41 Ok($res)
42 }
43 }
44 }
45}
46
47
48pub mod types;
49pub mod error;
50pub mod proxy;
51pub mod dbase;
52#[cfg(feature = "serde")]
53pub mod serde;
54
55pub use proxy::DeviceProxy;
56pub use dbase::DatabaseProxy;
57pub use error::{TangoError, TangoResult};
58pub use types::{
59 TangoDataType,
60 TangoDevState,
61 DispLevel,
62 DevSource,
63 CommandInfo,
64 CommandData,
65 DevEncoded,
66 AttributeInfo,
67 AttrQuality,
68 AttrWriteType,
69 AttrDataFormat,
70 AttributeData,
71 AttrValue,
72 DbDatum,
73 PropertyValue,
74 ErrSeverity,
75};