MCPcopy Index your code
hub / github.com/0x676e67/wreq-python / PyBufferProtocol

Interface PyBufferProtocol

src/buffer.rs:28–42  ·  view source on GitHub ↗

A trait to define common buffer behavior

Source from the content-addressed store, hash-verified

26
27/// A trait to define common buffer behavior
28pub trait PyBufferProtocol<'py>: IntoPyObject<'py> {
29 fn as_slice(&self) -> &[u8];
30
31 /// Consume self to build a bytes
32 fn into_bytes(self, py: Python<'py>) -> PyResult<Py<PyAny>> {
33 let buffer = self.into_py_any(py)?;
34 unsafe { PyObject::from_owned_ptr_or_err(py, ffi::PyBytes_FromObject(buffer.as_ptr())) }
35 }
36
37 /// Consume self to build a bytes
38 fn into_bytes_ref(self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
39 let buffer = self.into_py_any(py)?;
40 unsafe { Bound::from_owned_ptr_or_err(py, ffi::PyBytes_FromObject(buffer.as_ptr())) }
41 }
42}
43
44macro_rules! impl_buffer {
45 ($name:ident, $inner_type:ty) => {

Callers 11

bytesMethod · 0.80
bytesMethod · 0.80
_anextMethod · 0.80
getMethod · 0.80
__next__Method · 0.80
get_cookiesMethod · 0.80
peer_certificateMethod · 0.80
dataMethod · 0.80
binaryMethod · 0.80
pingMethod · 0.80
pongMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected