use std::{
marker::PhantomData,
ops::{Deref, DerefMut},
};
use libmqm_sys as mq;
pub type MQMD = MqStruct<'static, mq::MQMD>;
pub type MQMD1 = MqStruct<'static, mq::MQMD1>;
pub type MQGMO = MqStruct<'static, mq::MQGMO>;
pub type MQPMO<'a> = MqStruct<'a, mq::MQPMO>;
pub type MQCNO<'a> = MqStruct<'a, mq::MQCNO>;
pub type MQSCO<'a> = MqStruct<'a, mq::MQSCO>;
pub type MQCSP<'a> = MqStruct<'a, mq::MQCSP>;
pub type MQCD<'a> = MqStruct<'a, mq::MQCD>;
#[cfg(feature = "mqc_9_3_0_0")]
pub type MQBNO = MqStruct<'static, mq::MQBNO>;
pub type MQSD<'a> = MqStruct<'a, mq::MQSD>;
pub type MQOD<'a> = MqStruct<'a, mq::MQOD>;
pub type MQAIR<'a> = MqStruct<'a, mq::MQAIR>;
pub type MQCHARV<'a> = MqStruct<'a, mq::MQCHARV>;
pub type MQIMPO<'a> = MqStruct<'a, mq::MQIMPO>;
pub type MQDMPO = MqStruct<'static, mq::MQDMPO>;
pub type MQSMPO = MqStruct<'static, mq::MQSMPO>;
pub type MQMHBO = MqStruct<'static, mq::MQMHBO>;
pub type MQBMHO = MqStruct<'static, mq::MQBMHO>;
pub type MQPD = MqStruct<'static, mq::MQPD>;
pub type MQSRO = MqStruct<'static, mq::MQSRO>;
pub type MQSTS<'a> = MqStruct<'a, mq::MQSTS>;
pub type MQCBC<'a> = MqStruct<'a, mq::MQCBC>;
pub type MQCBD<'a> = MqStruct<'a, mq::MQCBD>;
pub type MQBO = MqStruct<'static, mq::MQBO>;
pub type MQCTLO<'a> = MqStruct<'a, mq::MQCTLO>;
#[derive(Debug, Clone)]
#[repr(transparent)]
pub struct MqStruct<'ptr, T> {
pub(super) struc: T,
_marker: PhantomData<&'ptr mut ()>, }
impl<T> MqStruct<'_, T> {
pub const fn new(struc: T) -> Self {
Self {
struc,
_marker: PhantomData,
}
}
}
impl<T> DerefMut for MqStruct<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.struc
}
}
impl<T> Deref for MqStruct<'_, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.struc
}
}
macro_rules! impl_min_version {
([$($lt:lifetime),*], $ty:ty) => {
impl <$($lt, )*> $ty {
#[inline]
#[doc = "Sets the `Version` field to a minimum"]
pub fn set_min_version(&mut self, version: $crate::types::MQLONG) {
self.Version = std::cmp::max(self.Version, version);
}
}
};
}
impl_min_version!([], MQGMO);
pub(crate) use impl_min_version;