(
&mut self,
mut words: impl Iterator<Item = &'a str>,
first_line: &'a str,
)
| 206 | } |
| 207 | |
| 208 | fn parse_statement( |
| 209 | &mut self, |
| 210 | mut words: impl Iterator<Item = &'a str>, |
| 211 | first_line: &'a str, |
| 212 | ) -> Result<Record<'a>, anyhow::Error> { |
| 213 | let location = self.location(); |
| 214 | let mut expected_error = None; |
| 215 | let mut rows_affected = None; |
| 216 | match words.next() { |
| 217 | Some("count") => { |
| 218 | rows_affected = Some( |
| 219 | words |
| 220 | .next() |
| 221 | .ok_or_else(|| anyhow!("missing count of rows affected"))? |
| 222 | .parse::<u64>() |
| 223 | .map_err(|err| anyhow!("parsing count of rows affected: {}", err))?, |
| 224 | ); |
| 225 | } |
| 226 | Some("ok") | Some("OK") => (), |
| 227 | Some("error") => expected_error = Some(parse_expected_error(first_line)), |
| 228 | _ => bail!("invalid statement disposition: {}", first_line), |
| 229 | }; |
| 230 | let sql = self.split_at(&DOUBLE_LINE_REGEX)?; |
| 231 | Ok(Record::Statement { |
| 232 | expected_error, |
| 233 | rows_affected, |
| 234 | sql, |
| 235 | location, |
| 236 | }) |
| 237 | } |
| 238 | |
| 239 | fn parse_query( |
| 240 | &mut self, |
no test coverage detected