fix(python-client): fixing paged search results to use a PyList instead

Changing from PyAny to PyList
This commit is contained in:
Scott Lyons 2024-08-15 08:20:59 -07:00
commit e99e898641

View file

@ -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 {
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: value.results.into_py(py),
results: list,
}
})
}
}