-
I did not find something relevant in google or this discussions tab, so I'm creating a new thread. Consider this example: #[pyclass]
pub struct Thing{
// pyclass-compatible trait contents
}
impl Thing {
pub fn start_something() -> Arc<Token> {
// ...
let token = Arc::new(Token::new(..))
// .. pass token to some threads ..
token
}
pub fn do_something(token: Arc<Token>) {
// ...
}
}
#[pymethods]
impl Thing {
fn start_something_py(&self) -> PyObject {
let arc = self.start_something();
// how to return something that returns the arc
// so that I can send it back to `do_something_py` in the future?
}
fn start_something_py(something: Py<?>) {
// how to move from a python reference to the arc I returned?
let arc: Arc<Token> = something.<?>.unwrap();
// ...
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
ntakouris
Jan 28, 2022
Replies: 1 comment
-
I made a #[pyclass]
pub struct TokenWrapper {
node_runner: Arc<Token>,
} and then on the python functions, you can accept a This could be automated with some macro implementing traits, generic trait implementations or maybe pyclass support for type aliases? |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ntakouris
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made a
and then on the python functions, you can accept a
PyRef<TokenWrapper>
.This could be automated with some macro implementing traits, generic trait implementations or maybe pyclass support for type aliases?