feat: static Event and Context types

This commit is contained in:
2025-03-13 16:01:52 -04:00
parent 96495b2a85
commit 95b7f38fc1
5 changed files with 21 additions and 29 deletions

View File

@@ -21,7 +21,11 @@ impl<'py> FromPyObject<'py> for StateMachine {
}
impl StateMachine {
pub fn get(&self, py: &Python, entity_id: EntityId) -> Result<Option<State>, PyErr> {
pub fn get<ContextEvent: for<'py> FromPyObject<'py>>(
&self,
py: &Python,
entity_id: EntityId,
) -> Result<Option<State<ContextEvent>>, PyErr> {
let args = (entity_id.to_string(),);
let state = self.0.call_method1(*py, "get", args)?;
state.extract(*py)