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 libmqm_sys::lib;
57
58let mut hconn = lib::MQHC_DEF_HCONN;
59let mut comp_code = lib::MQCC_UNKNOWN;
60let mut reason = lib::MQRC_NONE;
61let mut qmgr: lib::MQCHAR48 = [32; 48]; // All spaces = default qmgr
62
63unsafe {
64 lib::MQCONN(
65 &qmgr,
66 &mut hconn,
67 &mut comp_code,
68 &mut reason,
69 );
70 assert_eq!(reason, lib::MQRC_NONE, "MQRC");
71 assert_eq!(comp_code, lib::MQCC_OK, "MQCC");
72 lib::MQDISC(&mut hconn, &mut comp_code, &mut reason);
73};
74```
75
76## Features
77
78*/
79
80#![cfg_attr(feature = "docsrs", doc = document_features::document_features!())]
81
82/*!
83
84Minimum MQ client can be set using the `mqc_*` features
85*/
86
87#[cfg(feature = "bindgen")]
88#[rustfmt::skip]
89#[path ="bindgen.rs"]
90mod generated;
91
92#[cfg(not(feature = "bindgen"))]
93#[rustfmt::skip]
94#[path = "pregen/mod.rs"]
95mod generated;
96
97pub use generated::bindings as lib;
98pub use generated::function::*;
99
100#[cfg(feature = "mock")]
101pub use generated::mock;
102
103#[cfg(feature = "constant_lookup")]
104#[rustfmt::skip]
105pub mod str {
106 include!(concat!(env!("OUT_DIR"), "/str.rs"));
107}
108
109#[cfg(feature = "struct_defaults")]
110mod default;
111
112#[cfg(feature = "dlopen2")]
113pub mod dlopen2;
114
115#[cfg(feature = "link_api")]
116pub mod link;