summary refs log tree commit diff
path: root/rust/src/events/mod.rs
diff options
context:
space:
mode:
authorErik Johnston <erikj@element.io>2024-05-08 14:30:06 +0100
committerGitHub <noreply@github.com>2024-05-08 14:30:06 +0100
commit414ddcd45722be8a4a3f70d4b52c3b81be79118f (patch)
treec88190f9f3d7c2f9749589ba8c729d19d1e0c7a1 /rust/src/events/mod.rs
parentNote preset behaviour in `autocreate_auto_join_room_preset` docs (#17150) (diff)
downloadsynapse-414ddcd45722be8a4a3f70d4b52c3b81be79118f.tar.xz
Update PyO3 to 0.21 (#17162)
This version change requires a migration to a new API. See
https://pyo3.rs/v0.21.2/migration#from-020-to-021

This will fix the annoying warnings added when using the recent rust
nightly:

> warning: non-local `impl` definition, they should be avoided as they
go against expectation
Diffstat (limited to 'rust/src/events/mod.rs')
-rw-r--r--rust/src/events/mod.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/rust/src/events/mod.rs b/rust/src/events/mod.rs

index ee857b3d72..a4ade1a178 100644 --- a/rust/src/events/mod.rs +++ b/rust/src/events/mod.rs
@@ -20,20 +20,23 @@ //! Classes for representing Events. -use pyo3::{types::PyModule, PyResult, Python}; +use pyo3::{ + types::{PyAnyMethods, PyModule, PyModuleMethods}, + Bound, PyResult, Python, +}; mod internal_metadata; /// Called when registering modules with python. -pub fn register_module(py: Python<'_>, m: &PyModule) -> PyResult<()> { - let child_module = PyModule::new(py, "events")?; +pub fn register_module(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { + let child_module = PyModule::new_bound(py, "events")?; child_module.add_class::<internal_metadata::EventInternalMetadata>()?; - m.add_submodule(child_module)?; + m.add_submodule(&child_module)?; // We need to manually add the module to sys.modules to make `from // synapse.synapse_rust import events` work. - py.import("sys")? + py.import_bound("sys")? .getattr("modules")? .set_item("synapse.synapse_rust.events", child_module)?;