Ошибка при возврате вектора объектов документа с использованием pyo3
Возврат вектора объектов документа из ржавчины в питон не выполняется.
У меня есть реализация структуры и метода в ржавчине следующим образом.
use mongodb::{
bson::{Bson, Document},
error::Error,
sync::Client,
};
use pyo3::prelude::*;
#[pyclass]
pub struct SampleStruct{
docs: Vec<Document>,
}
#[pymethods]
impl SampleStruct{
#[new]
pub fn new() -> Self {...}
pub fn a_method(&self, some_string: &str) -> Vec<&Document> {...}
}
Вышеуказанное не удается со следующим сообщением
error[E0277]: the trait bound `std::vec::Vec<&bson::document::Document>: pyo3::callback::IntoPyCallbackOutput<_>` is not satisfied
--> src/fail_demo.rs:55:1
|
55 | #[pymethods]
| ^^^^^^^^^^^^ the trait `pyo3::callback::IntoPyCallbackOutput<_>` is not implemented for `std::vec::Vec<&bson::document::Document>`
|
::: /home/demo/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.11.1/src/callback.rs:169:8
|
169 | T: IntoPyCallbackOutput<U>,
| ----------------------- required by this bound in `pyo3::callback::convert`
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)