1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::{
execute::execute_with_parameters,
handles::{ParameterDescription, Statement, StatementImpl},
CursorImpl, Error, ParameterCollection, ResultSetMetadata,
};
pub struct Prepared<'open_connection> {
statement: StatementImpl<'open_connection>,
}
impl<'o> Prepared<'o> {
pub(crate) fn new(statement: StatementImpl<'o>) -> Self {
Self { statement }
}
pub fn execute(
&mut self,
params: impl ParameterCollection,
) -> Result<Option<CursorImpl<&mut StatementImpl<'o>>>, Error> {
execute_with_parameters(move || Ok(&mut self.statement), None, params)
}
pub fn describe_param(&self, parameter_number: u16) -> Result<ParameterDescription, Error> {
self.statement
.describe_param(parameter_number)
.into_result(&self.statement)
}
}
impl<'o> ResultSetMetadata for Prepared<'o> {
type Statement = StatementImpl<'o>;
fn stmt_ref(&self) -> &Self::Statement {
&self.statement
}
}