Get a value from the [ProxyRow]
(&self, index: I)
| 162 | impl ProxyRow { |
| 163 | /// Get a value from the [ProxyRow] |
| 164 | pub fn try_get<T, I: crate::ColIdx>(&self, index: I) -> Result<T, DbErr> |
| 165 | where |
| 166 | T: ValueType, |
| 167 | { |
| 168 | if let Some(index) = index.as_str() { |
| 169 | T::try_from( |
| 170 | self.values |
| 171 | .get(index) |
| 172 | .ok_or_else(|| query_err(format!("No column for ColIdx {index:?}")))? |
| 173 | .clone(), |
| 174 | ) |
| 175 | .map_err(type_err) |
| 176 | } else if let Some(index) = index.as_usize() { |
| 177 | let (_, value) = self |
| 178 | .values |
| 179 | .iter() |
| 180 | .nth(*index) |
| 181 | .ok_or_else(|| query_err(format!("Column at index {index} not found")))?; |
| 182 | T::try_from(value.clone()).map_err(type_err) |
| 183 | } else { |
| 184 | unreachable!("Missing ColIdx implementation for ProxyRow"); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /// An iterator over the keys and values of a proxy row |
| 189 | pub fn into_column_value_tuples(self) -> impl Iterator<Item = (String, Value)> { |