Skip to content

Return multiple structs from Rust method back to Python #3567

Discussion options

You must be logged in to vote

Sorry for the slow reply. I think it's sufficient to just use PyObject as the return type from your function, and use e.g. create_event.into_py(py) to convert the typed instances into them.

#[pymethods]
impl Watcher {
    pub fn get(&self, py: Python) -> PyResult<PyObject> { // Question: What should be the typing here? 
        // create and returns an instance of either AccessEvent, CreateEvent, or DeleteEvent
    }
}

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@roma-glushko
Comment options

@davidhewitt
Comment options

Answer selected by roma-glushko
@roma-glushko
Comment options

@davidhewitt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants