Get the underlying buffer from the specified python object.
(py: Python, obj: &PyObject)
| 163 | impl PyBuffer { |
| 164 | /// Get the underlying buffer from the specified python object. |
| 165 | pub fn get(py: Python, obj: &PyObject) -> PyResult<PyBuffer> { |
| 166 | unsafe { |
| 167 | let mut buf = Box::new(mem::zeroed::<ffi::Py_buffer>()); |
| 168 | err::error_on_minusone( |
| 169 | py, |
| 170 | ffi::PyObject_GetBuffer(obj.as_ptr(), &mut *buf, ffi::PyBUF_FULL_RO), |
| 171 | )?; |
| 172 | validate(&buf); |
| 173 | Ok(PyBuffer(buf)) |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | /// Gets the pointer to the start of the buffer memory. |
| 178 | /// |