(ty: &Type, raw: &'a [u8])
| 40 | impl<'a> FromSql<'a> for IntervalWrap { |
| 41 | fn from_sql(ty: &Type, raw: &'a [u8]) -> Result<Self, Box<dyn Error + Sync + Send>> { |
| 42 | if !matches!(*ty, Type::INTERVAL) { |
| 43 | return Err(anyhow!("Cannot read Interval sql from type: {}", ty).into()); |
| 44 | } |
| 45 | let mut result = IntervalWrap(Default::default()); |
| 46 | let mut raw = Cursor::new(raw); |
| 47 | result.0.nanos = raw.read_i64::<NetworkEndian>()? as i128 * 1000; |
| 48 | result.0.days = raw.read_i32::<NetworkEndian>()? as i64; |
| 49 | result.0.months = raw.read_i32::<NetworkEndian>()? as i64; |
| 50 | Ok(result) |
| 51 | } |
| 52 | |
| 53 | fn accepts(ty: &Type) -> bool { |
| 54 | matches!(*ty, Type::INTERVAL) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | impl From<IntervalWrap> for Interval { |
| 59 | fn from(value: IntervalWrap) -> Self { |
nothing calls this directly
no test coverage detected