Skip to content

Commit 8146b51

Browse files
committed
[update] the event publisher, event loop, and events to derive debug.
1 parent fe2bff4 commit 8146b51

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

crates/lambda-platform/src/winit/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ pub mod winit_exports {
3535
}
3636

3737
/// Loop wrapping for the winit event loop.
38-
pub struct Loop<E: 'static> {
38+
pub struct Loop<E: 'static + std::fmt::Debug> {
3939
event_loop: EventLoop<E>,
4040
}
4141

42-
pub fn create_event_loop<Events: 'static>() -> Loop<Events> {
42+
pub fn create_event_loop<Events: 'static + std::fmt::Debug>() -> Loop<Events> {
4343
let event_loop = EventLoop::<Events>::with_user_event();
4444
return Loop { event_loop };
4545
}
@@ -85,11 +85,12 @@ fn construct_window_size(
8585
};
8686
}
8787

88-
pub struct EventLoopPublisher<E: 'static> {
88+
#[derive(Clone, Debug)]
89+
pub struct EventLoopPublisher<E: 'static + std::fmt::Debug> {
8990
winit_proxy: EventLoopProxy<E>,
9091
}
9192

92-
impl<E: 'static> EventLoopPublisher<E> {
93+
impl<E: 'static + std::fmt::Debug> EventLoopPublisher<E> {
9394
/// Instantiate a new EventLoopPublisher from an event loop proxy.
9495
#[inline]
9596
pub fn new(winit_proxy: EventLoopProxy<E>) -> Self {
@@ -99,11 +100,14 @@ impl<E: 'static> EventLoopPublisher<E> {
99100
/// Send an event
100101
#[inline]
101102
pub fn send_event(&self, event: E) {
102-
self.winit_proxy.send_event(event);
103+
self
104+
.winit_proxy
105+
.send_event(event)
106+
.expect("Failed to send event");
103107
}
104108
}
105109

106-
impl<E: 'static> Loop<E> {
110+
impl<E: 'static + std::fmt::Debug> Loop<E> {
107111
pub fn create_publisher(&mut self) -> EventLoopPublisher<E> {
108112
let proxy = self.event_loop.create_proxy();
109113
return EventLoopPublisher::new(proxy);

lambda/src/core/events.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
use std::time::Instant;
22

3+
/// events generated by kernel interactions with the component.
4+
#[derive(Debug)]
35
pub enum ComponentEvent {
46
Attached { name: String },
57
Detached { name: String },
68
}
79

10+
/// Window events are generated in response to window events coming from
11+
/// the windowing system.
12+
#[derive(Debug)]
813
pub enum WindowEvent {
914
Close,
1015
Resize { width: u32, height: u32 },
1116
}
1217

18+
/// Kernel events are generated by the kernel itself
19+
#[derive(Debug)]
1320
pub enum KernelEvent {
1421
Initialized,
1522
Shutdown,
1623
}
1724

1825
/// Generic Event Enum which encapsulates all possible events that will be emitted
1926
/// by the LambdaKernel
27+
#[derive(Debug)]
2028
pub enum Events {
2129
Component {
2230
event: ComponentEvent,

lambda/src/core/render/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl RenderContextBuilder {
130130
let mut gpu = internal::GpuBuilder::new()
131131
.with_render_queue_type(internal::RenderQueueType::Graphical)
132132
.build(&mut instance, Some(&surface))
133-
.expect("Failed to build a GPU.");
133+
.expect("Failed to build a GPU with a graphical render queue.");
134134

135135
// Build command pool and allocate a single buffer named Primary
136136
let command_pool = internal::CommandPoolBuilder::new().build(&gpu);

0 commit comments

Comments
 (0)