mysql_connector/model/
plain.rs1use {
2 super::{FromQueryResult, FromQueryResultMapping},
3 crate::{connection::types::Column, error::ParseError, types::Value},
4};
5
6impl super::ModelData for Vec<Value> {
7 const TABLE: &'static str = "";
8 const TABLE_WITH_POINT: &'static str = "";
9}
10
11impl FromQueryResult for Vec<Value> {
12 type Mapping = EmptyMapping;
13
14 fn from_mapping_and_row(
15 mapping: &Self::Mapping,
16 row: &mut Vec<Value>,
17 ) -> std::result::Result<Self, ParseError> {
18 if row.len() != mapping.len() {
19 return Err(ParseError::RowLengthMismatch);
20 }
21 Ok(std::mem::take(row))
22 }
23}
24
25#[derive(Default)]
26pub struct EmptyMapping(usize);
27
28impl EmptyMapping {
29 pub fn len(&self) -> usize {
30 self.0
31 }
32}
33
34impl FromQueryResultMapping<Vec<Value>> for EmptyMapping {
35 fn set_mapping_inner(&mut self, _column: &Column, _name: &str, _index: usize) {
36 self.0 += 1;
37 }
38
39 fn set_mapping(&mut self, _column: &Column, _name: &str, _index: usize) {
40 self.0 += 1;
41 }
42
43 fn from_columns(columns: &[Column]) -> Self {
44 Self(columns.len())
45 }
46}