use crate::errors::OxiaError;
use crate::proto;
use tokio::sync::oneshot;
pub(crate) struct Pending<Req, Resp> {
pub(crate) request: Req,
pub(crate) callback: oneshot::Sender<Result<Resp, OxiaError>>,
}
impl<Req, Resp> Pending<Req, Resp> {
pub(crate) fn new(request: Req) -> (Self, oneshot::Receiver<Result<Resp, OxiaError>>) {
let (tx, rx) = oneshot::channel();
(
Pending {
request,
callback: tx,
},
rx,
)
}
}
pub(crate) type PendingPut = Pending<proto::PutRequest, proto::PutResponse>;
pub(crate) type PendingDelete = Pending<proto::DeleteRequest, proto::DeleteResponse>;
pub(crate) type PendingDeleteRange = Pending<proto::DeleteRangeRequest, proto::DeleteRangeResponse>;
pub(crate) type PendingGet = Pending<proto::GetRequest, proto::GetResponse>;