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
13Compile time dynamic linking and run-time dynamic linking is supported.
14
15Developers must download the [MQI library](https://ibm.biz/mq94redistclients) directly from IBM.
16Refer to the [Usage](#usage) instructions.
17
18Safety
19------
20
21Functions provided in this crate are the raw `unsafe` functions exposed from the
22IBM provided library. Developers should build safe rust API wrappers over these functions.
23Developers who do not want to use the unsafe API should use the
24[mqi](https://github.com/advantic-au/mqi) crate for a *safe* API over the MQI.
25
26Usage
27-----
28
291. Download and install the redistributable client from IBM:
30  <https://ibm.biz/mq94redistclients>
31
322. Install the client in `/opt/mqm` or another location.
33
343. Set the MQ_HOME environment variable to the installed location.
35
36    ```bash
37    MQ_HOME=/opt/mqm
38    ```
39
404. Add the `libmqm_sys` crate to your project:
41
42    ```sh
43    cargo add libmqm_sys
44    ```
45
465. Use the crate in your source code:
47
48    ```rust
49    use libmqm_sys as mqsys;
50    ```
51
52Example
53-------
54
55```no_run
56use std::ptr::addr_of_mut;
57use libmqm_sys::lib;
58
59let mut hconn = lib::MQHC_DEF_HCONN;
60let mut comp_code = lib::MQCC_UNKNOWN;
61let mut reason = lib::MQRC_NONE;
62let mut qmgr: [lib::MQCHAR; 48] = [32; 48]; // All spaces = default qmgr
63
64unsafe {
65    lib::MQCONN(
66        addr_of_mut!(qmgr).cast(),
67        addr_of_mut!(hconn),
68        addr_of_mut!(comp_code),
69        addr_of_mut!(reason),
70    );
71    assert_eq!(reason, lib::MQRC_NONE, "MQRC");
72    assert_eq!(comp_code, lib::MQCC_OK, "MQCC");
73    lib::MQDISC(addr_of_mut!(hconn), addr_of_mut!(comp_code), addr_of_mut!(reason));
74};
75```
76
77## Features
78
79*/
80
81#![doc = document_features::document_features!()]
82
83/*!
84 *
85 * Minimum MQ client can be set using the `mqc_*` features
86*/
87
88#[cfg(feature = "bindgen")]
89pub mod lib {
90    //! Constants, types and structures generated by bindgen from the MQ client C library
91    mod bindgen;
92    #[doc(inline)]
93    pub use bindgen::*;
94}
95
96#[cfg(not(feature = "bindgen"))]
97pub mod lib {
98    //! Constants, types and structures generated by bindgen from the MQ client C library
99    mod pregen;
100    #[doc(inline)]
101    pub use pregen::*;
102}
103
104#[cfg(not(feature = "versiongen"))]
105#[allow(clippy::unreadable_literal)]
106pub mod version {
107    mod pregen;
108    #[doc(inline)]
109    pub use pregen::*;
110}
111
112#[cfg(feature = "versiongen")]
113#[allow(clippy::unreadable_literal)]
114pub mod version {
115    include!(concat!(env!("OUT_DIR"), "/version.rs"));
116}
117
118mod default;
119
120mod function;
121#[doc(inline)]
122pub use function::*;
123
124#[cfg(feature = "dlopen2")]
125pub mod dlopen2;
126
127#[cfg(feature = "link_api")]
128pub mod link;