MCPcopy Create free account
hub / github.com/HFQR/xitca-web / from_sql_ext

Method from_sql_ext

postgres/src/from_sql.rs:56–74  ·  view source on GitHub ↗
(ty: &Type, (range, buf): (&Range<usize>, &'a Bytes))

Source from the content-addressed store, hash-verified

54
55impl<'a> FromSqlExt<'a> for BytesStr {
56 fn from_sql_ext(ty: &Type, (range, buf): (&Range<usize>, &'a Bytes)) -> Result<Self, FromSqlError> {
57 // copy/paste from postgres-protocol dependency.
58 fn adjust_start(name: &str, range_start: usize, buf: &Bytes) -> Result<usize, FromSqlError> {
59 if buf[range_start] == 1u8 {
60 Ok(range_start + 1)
61 } else {
62 Err(format!("only {name} version 1 supported").into())
63 }
64 }
65
66 let start = match ty.name() {
67 "ltree" => adjust_start("ltree", range.start, buf)?,
68 "lquery" => adjust_start("lquery", range.start, buf)?,
69 "ltxtquery" => adjust_start("ltxtquery", range.start, buf)?,
70 _ => range.start,
71 };
72
73 BytesStr::try_from(buf.slice(start..range.end)).map_err(Into::into)
74 }
75
76 #[inline]
77 fn accepts_ext(ty: &Type) -> bool {

Callers

nothing calls this directly

Calls 4

nameMethod · 0.45
map_errMethod · 0.45
sliceMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected