Parse an [`Lsn`] from the first column of the provided [`tiberius::Row`]. Returns an error if the provided slice doesn't have exactly one row.
(result: &[tiberius::Row])
| 208 | /// |
| 209 | /// Returns an error if the provided slice doesn't have exactly one row. |
| 210 | fn parse_lsn(result: &[tiberius::Row]) -> Result<Lsn, SqlServerError> { |
| 211 | match result { |
| 212 | [row] => { |
| 213 | let val = row |
| 214 | .try_get::<&[u8], _>(0)? |
| 215 | .ok_or_else(|| SqlServerError::NullLsn)?; |
| 216 | if val.is_empty() { |
| 217 | Err(SqlServerError::NullLsn) |
| 218 | } else { |
| 219 | let lsn = Lsn::try_from(val).map_err(|msg| SqlServerError::InvalidData { |
| 220 | column_name: "lsn".to_string(), |
| 221 | error: msg, |
| 222 | })?; |
| 223 | Ok(lsn) |
| 224 | } |
| 225 | } |
| 226 | other => Err(SqlServerError::InvalidData { |
| 227 | column_name: "lsn".to_string(), |
| 228 | error: format!("expected 1 column, got {other:?}"), |
| 229 | }), |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /// Queries the specified capture instance and returns all changes from |
| 234 | /// `[start_lsn, end_lsn)`, ordered by `start_lsn` in an ascending fashion. |
no test coverage detected