@@ -20,7 +20,10 @@ use lambda::{
2020 RenderContext ,
2121 } ,
2222 runtime:: start_runtime,
23- runtimes:: ApplicationRuntimeBuilder ,
23+ runtimes:: {
24+ application:: ComponentResult ,
25+ ApplicationRuntimeBuilder ,
26+ } ,
2427} ;
2528
2629pub struct DemoComponent {
@@ -32,8 +35,11 @@ pub struct DemoComponent {
3235 height : u32 ,
3336}
3437
35- impl Component for DemoComponent {
36- fn on_attach ( & mut self , render_context : & mut RenderContext ) {
38+ impl Component < ComponentResult , String > for DemoComponent {
39+ fn on_attach (
40+ & mut self ,
41+ render_context : & mut RenderContext ,
42+ ) -> Result < ComponentResult , String > {
3743 println ! ( "Attached the demo component to the renderer" ) ;
3844 let render_pass =
3945 render_pass:: RenderPassBuilder :: new ( ) . build ( & render_context) ;
@@ -50,11 +56,20 @@ impl Component for DemoComponent {
5056 self . render_pipeline_id = Some ( render_context. attach_pipeline ( pipeline) ) ;
5157
5258 println ! ( "Attached the DemoComponent." ) ;
59+ return Ok ( ComponentResult :: Success ) ;
5360 }
5461
55- fn on_detach ( self : & mut DemoComponent , render_context : & mut RenderContext ) { }
62+ fn on_detach (
63+ self : & mut DemoComponent ,
64+ render_context : & mut RenderContext ,
65+ ) -> Result < ComponentResult , String > {
66+ return Ok ( ComponentResult :: Success ) ;
67+ }
5668
57- fn on_event ( self : & mut DemoComponent , event : Events ) {
69+ fn on_event (
70+ self : & mut DemoComponent ,
71+ event : Events ,
72+ ) -> Result < ComponentResult , String > {
5873 match event {
5974 Events :: Runtime { event, issued_at } => match event {
6075 lambda:: events:: RuntimeEvent :: Shutdown => {
@@ -101,16 +116,21 @@ impl Component for DemoComponent {
101116 }
102117 } ,
103118 _ => { }
104- }
119+ } ;
120+ return Ok ( ComponentResult :: Success ) ;
105121 }
106122
107- fn on_update ( self : & mut DemoComponent , last_frame : & std:: time:: Duration ) {
123+ fn on_update (
124+ self : & mut DemoComponent ,
125+ last_frame : & std:: time:: Duration ,
126+ ) -> Result < ComponentResult , String > {
108127 match last_frame. as_millis ( ) > 20 {
109128 true => {
110129 println ! ( "[WARN] Last frame took {}ms" , last_frame. as_millis( ) ) ;
111130 }
112131 false => { }
113- }
132+ } ;
133+ return Ok ( ComponentResult :: Success ) ;
114134 }
115135 fn on_render (
116136 self : & mut DemoComponent ,
0 commit comments