use crate::{
result::{Error, ResultComp, ResultCompErr},
structs, types,
};
pub struct OpenParamOption<'a, T> {
pub mqod: structs::MQOD<'a>,
pub options: T,
}
pub type OpenParam<'a> = OpenParamOption<'a, types::MQOO>;
#[diagnostic::on_unimplemented(
message = "{Self} does not implement `OpenOption` so it can't be used as an argument for MQI open"
)]
pub unsafe trait OpenOption<'oo, T> {
fn apply_param(&self, param: &mut OpenParamOption<'oo, T>);
}
pub unsafe trait OpenValue<S> {
type Error: From<Error> + std::fmt::Debug;
fn open_consume<'oo, F>(param: &mut OpenParam<'oo>, mqi: F) -> ResultCompErr<Self, Self::Error>
where
F: FnOnce(&mut OpenParam<'oo>) -> ResultComp<S>,
Self: std::marker::Sized;
}
pub unsafe trait OpenAttr<S, O> {
fn open_extract<'a, F>(param: &mut OpenParamOption<'a, O>, mqi: F) -> ResultComp<(Self, S)>
where
F: FnOnce(&mut OpenParamOption<'a, O>) -> ResultComp<S>,
Self: Sized;
}