MCPcopy Create free account
hub / github.com/TankHQ/tank / from_sql

Method from_sql

tank-postgres/src/interval_wrap.rs:42–56  ·  view source on GitHub ↗
(ty: &Type, raw: &'a [u8])

Source from the content-addressed store, hash-verified

40impl<'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
58impl From<IntervalWrap> for Interval {
59 fn from(value: IntervalWrap) -> Self {

Callers

nothing calls this directly

Calls 1

IntervalWrapClass · 0.85

Tested by

no test coverage detected