##// 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 Ok(unsafe { leaked.map(py, |idx| PySharedIndex { inner: &idx.index }) })
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 /// Full extraction of the proxy index object as received in PyO3 to a
177 /// Full extraction of the proxy index object as received in PyO3 to a
170 /// [`CoreIndex`] reference.
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 /// [`UnsafePyLeaked::try_borrow`]: the caller must not leak the inner
183 /// [`UnsafePyLeaked::try_borrow`]: the caller must not leak the inner
174 /// reference.
184 /// reference.
175 pub(crate) unsafe fn proxy_index_extract<'py>(
185 pub(crate) unsafe fn proxy_index_extract<'py>(
176 index_proxy: &Bound<'py, PyAny>,
186 index_proxy: &Bound<'py, PyAny>,
177 ) -> PyResult<&'py CoreIndex> {
187 ) -> PyResult<&'py CoreIndex> {
178 let (py, idx_proxy) = to_cpython_py_object(index_proxy);
188 let (py, py_leaked) = proxy_index_py_leak(index_proxy)?;
179 let py_leaked = py_rust_index_to_graph(py, idx_proxy)?;
180 let py_shared = &*unsafe {
189 let py_shared = &*unsafe {
181 py_leaked
190 py_leaked
182 .try_borrow(py)
191 .try_borrow(py)
General Comments 0
You need to be logged in to leave comments. Login now