use crate::resp::{Command, Response};
use std::marker::PhantomData;
pub struct PreparedCommand<'a, E, R = ()>
where
R: Response,
{
phantom: PhantomData<fn(&'a ()) -> R>,
pub executor: E,
pub command: Command,
pub retry_on_error: Option<bool>,
}
impl<'a, E, R> PreparedCommand<'a, E, R>
where
R: Response,
{
#[must_use]
pub fn new(executor: E, command: Command) -> Self {
PreparedCommand {
phantom: PhantomData,
executor,
command,
retry_on_error: None,
}
}
pub fn retry_on_error(mut self, retry_on_error: bool) -> Self {
self.retry_on_error = Some(retry_on_error);
self
}
pub fn command(&self) -> &Command {
&self.command
}
}
pub(crate) fn prepare_command<'a, E, R: Response>(
executor: E,
command: impl Into<Command>,
) -> PreparedCommand<'a, E, R> {
PreparedCommand::new(executor, command.into())
}