MCPcopy Create free account
hub / github.com/0x676e67/wreq-python / extract_bound

Method extract_bound

src/client/typing/cookie.rs:173–189  ·  view source on GitHub ↗
(ob: &Bound<'_, PyAny>)

Source from the content-addressed store, hash-verified

171
172impl FromPyObject<'_> for CookieExtractor {
173 fn extract_bound(ob: &Bound<'_, PyAny>) -> PyResult<Self> {
174 let dict = ob.downcast::<PyDict>()?;
175 dict.iter()
176 .try_fold(Vec::with_capacity(dict.len()), |mut cookies, (k, v)| {
177 let cookie = {
178 let mut cookie = String::with_capacity(10);
179 cookie.push_str(k.extract::<PyBackedStr>()?.as_ref());
180 cookie.push('=');
181 cookie.push_str(v.extract::<PyBackedStr>()?.as_ref());
182 HeaderValue::from_maybe_shared(Bytes::from(cookie)).map_err(Error::from)?
183 };
184
185 cookies.push(cookie);
186 Ok(cookies)
187 })
188 .map(CookieExtractor)
189 }
190}

Callers

nothing calls this directly

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected