As of version 0.0.1 the DefaultRuntime accepts an initialization function that returns a trait object.
This results in unneeded heap allocation and dynamic dispatch.
Instead, the API should be re-written to allow the compiler to statically determine the types involved.
The user will have to implement an EventHandler trait:
pubtraitEventHandler<O:Serialize,E:Display,I:LambdaContext>{fninitialize(&mutself) -> Result<(),E>;fnon_event(&mutself,event:&str,context:&I) -> Result<O,E>;}Types implementing it, perform Lambda instance initialization once inside initialize and event handling inside on_event.
Any resources can be part of the struct implementing the EventHandler trait.
The on_event should take a &str as the event string instead of the previous Option<&str> to simplify users' functions.
As of version
0.0.1theDefaultRuntimeaccepts an initialization function that returns a trait object.This results in unneeded heap allocation and dynamic dispatch.
Instead, the API should be re-written to allow the compiler to statically determine the types involved.
The user will have to implement an
EventHandlertrait:Types implementing it, perform Lambda instance initialization once inside
initializeand event handling insideon_event.Any resources can be part of the struct implementing the
EventHandlertrait.The
on_eventshould take a&stras the event string instead of the previousOption<&str>to simplify users' functions.