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

Function encode_bind

postgres/src/driver/codec/encode.rs:235–269  ·  view source on GitHub ↗
(
    stmt_name: &str,
    types: &[Type],
    params: P,
    portal_name: &str,
    buf: &mut BytesMut,
)

Source from the content-addressed store, hash-verified

233}
234
235fn encode_bind<P>(
236 stmt_name: &str,
237 types: &[Type],
238 params: P,
239 portal_name: &str,
240 buf: &mut BytesMut,
241) -> Result<(), Error>
242where
243 P: AsParams,
244{
245 let params = params.into_iter();
246 if params.len() != types.len() {
247 return Err(Error::from(InvalidParamCount {
248 expected: types.len(),
249 params: params.len(),
250 }));
251 }
252
253 let params = params.zip(types);
254
255 protocol::bind(
256 portal_name,
257 stmt_name,
258 params.clone().map(|(p, ty)| p.borrow_to_sql().encode_format(ty) as _),
259 params,
260 |(p, ty), buf| {
261 let is_null = p.borrow_to_sql().to_sql_checked(ty, buf)?;
262 Ok(match is_null {
263 IsNull::No => protocol::IsNull::No,
264 IsNull::Yes => protocol::IsNull::Yes,
265 })
266 },
267 buf,
268 )
269}

Callers 2

encode_stmt_queryFunction · 0.85
encodeMethod · 0.85

Calls 5

bindFunction · 0.85
into_iterMethod · 0.45
lenMethod · 0.45
mapMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected