fix(python-client): fixing paged search results to use a PyList instead
Changing from PyAny to PyList
This commit is contained in:
parent
f4ba4a9c39
commit
e99e898641
1 changed files with 12 additions and 7 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use crate::models::PagedSearchResult;
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::types::PyList;
|
||||
|
||||
pub mod asynchronous;
|
||||
pub mod synchronous;
|
||||
|
|
@ -11,7 +12,7 @@ pub struct PyPagedSearchResult {
|
|||
pub offset: u32,
|
||||
pub limit: u32,
|
||||
pub total: u32,
|
||||
pub results: PyObject,
|
||||
pub results: Py<PyList>,
|
||||
}
|
||||
|
||||
#[cfg_attr(all(feature = "python"), pymethods)]
|
||||
|
|
@ -23,12 +24,16 @@ impl PyPagedSearchResult {
|
|||
|
||||
impl<T: IntoPy<PyObject>> From<PagedSearchResult<T>> for PyPagedSearchResult {
|
||||
fn from(value: PagedSearchResult<T>) -> Self {
|
||||
Python::with_gil(|py| PyPagedSearchResult {
|
||||
query: value.query,
|
||||
offset: value.offset,
|
||||
limit: value.limit,
|
||||
total: value.total,
|
||||
results: value.results.into_py(py),
|
||||
Python::with_gil(|py| {
|
||||
let list =
|
||||
PyList::new_bound(py, value.results.into_iter().map(|v| v.into_py(py))).unbind();
|
||||
PyPagedSearchResult {
|
||||
query: value.query,
|
||||
offset: value.offset,
|
||||
limit: value.limit,
|
||||
total: value.total,
|
||||
results: list,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue