##// END OF EJS Templates
rust-pyo3: intermediate ProxyIndex extraction...
Georges Racinet -
r53424:64a61804 default
parent child Browse files
Show More
@@ -166,17 +166,26 pub fn py_rust_index_to_graph(
166 166 Ok(unsafe { leaked.map(py, |idx| PySharedIndex { inner: &idx.index }) })
167 167 }
168 168
169 pub(crate) fn proxy_index_py_leak<'py>(
170 index_proxy: &Bound<'py, PyAny>,
171 ) -> PyResult<(cpython::Python<'py>, cpython::UnsafePyLeaked<PySharedIndex>)> {
172 let (py, idx_proxy) = to_cpython_py_object(index_proxy);
173 let py_leaked = py_rust_index_to_graph(py, idx_proxy)?;
174 Ok((py, py_leaked))
175 }
176
169 177 /// Full extraction of the proxy index object as received in PyO3 to a
170 178 /// [`CoreIndex`] reference.
171 179 ///
172 /// The safety invariants to maintain are those of the underlying
180 /// # Safety
181 ///
182 /// The invariants to maintain are those of the underlying
173 183 /// [`UnsafePyLeaked::try_borrow`]: the caller must not leak the inner
174 184 /// reference.
175 185 pub(crate) unsafe fn proxy_index_extract<'py>(
176 186 index_proxy: &Bound<'py, PyAny>,
177 187 ) -> PyResult<&'py CoreIndex> {
178 let (py, idx_proxy) = to_cpython_py_object(index_proxy);
179 let py_leaked = py_rust_index_to_graph(py, idx_proxy)?;
188 let (py, py_leaked) = proxy_index_py_leak(index_proxy)?;
180 189 let py_shared = &*unsafe {
181 190 py_leaked
182 191 .try_borrow(py)
General Comments 0
You need to be logged in to leave comments. Login now