Skip to main content

libmqm_sys/
lib.rs

1/*!
2
3Bindings to the IBM® MQ Interface (MQI), Programmable Command Format (PCF) and MQ Administration Interface (MQAI) C libraries.
4
5Overview
6--------
7
8You can use `libmqm_sys` to:
9
10- Connect to an IBM MQ server to send and receive MQ messages through the MQI functions
11- Administer IBM MQ server through the PCF structures and MQAI functions
12- Create, send, and receive PCF messages
13- Develop MQ exit programs (untested)
14
15Compile time dynamic linking and run-time dynamic linking is supported.
16
17Developers must download the [MQI library](https://ibm.biz/mq94redistclients) directly from IBM.
18Refer to the [Usage](#usage) instructions.
19
20Safety
21------
22
23Functions provided in this crate are the raw `unsafe` functions exposed from the
24IBM provided library. Developers should build safe rust API wrappers over these functions.
25Developers who do not want to use the unsafe API should use the
26[mqi](https://github.com/advantic-au/mqi) crate for a *safe* API over the MQI.
27
28Usage
29-----
30
311. Download and install the redistributable client from IBM:
32   <https://ibm.biz/mq94redistclients>
33
342. Install the client in `/opt/mqm` or another location.
35
363. Set the `MQ_HOME` environment variable to the installed location.
37
38    ```bash
39    MQ_HOME=/opt/mqm
40    ```
41
424. Add the `libmqm_sys` crate to your project:
43
44    ```sh
45    cargo add libmqm_sys
46    ```
47
485. Use the crate in your source code:
49
50    ```rust
51    use libmqm_sys as mq;
52    ```
53
54Example
55-------
56
57```no_run
58use libmqm_sys as mq;
59
60let mut hconn = mq::MQHC_DEF_HCONN;
61let mut comp_code = mq::MQCC_UNKNOWN;
62let mut reason = mq::MQRC_NONE;
63let mut qmgr: mq::MQCHAR48 = [32; 48]; // All spaces = default qmgr
64
65unsafe {
66    mq::MQCONN(
67        &qmgr,
68        &mut hconn,
69        &mut comp_code,
70        &mut reason,
71    );
72    assert_eq!(reason, mq::MQRC_NONE, "MQRC");
73    assert_eq!(comp_code, mq::MQCC_OK, "MQCC");
74    mq::MQDISC(&mut hconn, &mut comp_code, &mut reason);
75};
76```
77
78## Features
79
80*/
81
82#![cfg_attr(feature = "docsrs", doc = document_features::document_features!())]
83
84/*!
85
86Minimum MQ client can be set using the `mqc_*` features
87*/
88
89/*!
90
91Support
92-------
93
94This crate is not approved, endorsed, acknowledged, or supported by IBM. You cannot use
95IBM formal support channels (Cases/PMRs) for assistance on the use of this crate.
96
97Documentation
98-------------
99
100Documentation of all API functions, arguments, structures, type aliases, and constants are derived
101from the MQ library header files. Accuracy of the documentation is dependent on IBM supplied header
102files.
103
104 */
105#![cfg_attr(docsrs, feature(doc_cfg))]
106
107#[cfg(feature = "bindgen")]
108#[rustfmt::skip]
109#[path ="bindgen.rs"]
110mod generated;
111
112#[cfg(not(feature = "bindgen"))]
113#[rustfmt::skip]
114#[path = "pregen/mod.rs"]
115mod generated;
116
117pub use generated::function::*;
118
119pub use generated::bindings::mqi::*;
120
121pub mod version {
122    /*!
123       MQ library version information used in generation of the bindings
124    */
125    pub use super::generated::bindings::version::*;
126}
127
128#[cfg(feature = "pcf")]
129pub mod pcf {
130    /*!
131       Bindings to the IBM MQ [`Programmable Command Formats`](https://www.ibm.com/docs/en/SSFKSJ_latest/refadmin/q086860_.html)
132    */
133    pub use super::generated::bindings::pcf::*;
134}
135
136#[cfg(feature = "mqai")]
137pub mod mqai {
138    /*!
139       Bindings to the IBM MQ [`Administrative Interface`](https://www.ibm.com/docs/en/SSFKSJ_latest/refadmin/q089130_.html)
140    */
141    pub use super::generated::bindings::mqai::*;
142}
143
144#[cfg(feature = "exits")]
145pub mod exits {
146    /*!
147       Bindings to the IBM MQ [`exits`](https://www.ibm.com/docs/en/SSFKSJ_latest/develop/q027670_.html)
148    */
149    pub use super::generated::bindings::exits::*;
150}
151
152#[cfg(feature = "mock")]
153pub use generated::mock;
154
155#[cfg(feature = "constant_lookup")]
156#[rustfmt::skip]
157pub mod str {
158    include!(concat!(env!("OUT_DIR"), "/str.rs"));
159}
160
161#[cfg(feature = "struct_defaults")]
162mod default;
163
164#[cfg(feature = "dlopen2")]
165pub mod dlopen2;
166
167#[cfg(feature = "link_api")]
168pub mod link;