From 9606c5208f2fe91937c4dc5c53b5eae44f20e417 Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Sat, 18 Mar 2023 20:34:45 -0400 Subject: [PATCH] impl deref for UefiFb change lifetimes to 'a (was 'static) --- src/uefi_fb/mod.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/uefi_fb/mod.rs b/src/uefi_fb/mod.rs index d9b70af..e7e0950 100644 --- a/src/uefi_fb/mod.rs +++ b/src/uefi_fb/mod.rs @@ -18,9 +18,17 @@ pub struct UefiFb<'a> { gop: ScopedProtocol<'a, GraphicsOutput<'a>> } -impl UefiFb<'_> { +impl<'a> core::ops::Deref for UefiFb<'a> { + type Target = ScopedProtocol<'a, GraphicsOutput<'a>>; - pub fn new() -> UefiFb<'static> { + fn deref(&self) -> &Self::Target { + &self.gop + } +} + +impl<'a> UefiFb<'a> { + + pub fn new() -> UefiFb<'a> { let st_ref = unsafe { uefi_services::system_table().as_ref() }; let bt = st_ref.boot_services(); @@ -68,7 +76,7 @@ impl UefiFb<'_> { } // Fill the screen with color. - fn fb_blt_fill(&mut self, color: BltPixel, dest: (usize, usize), dims: (usize, usize)) { + pub fn fb_blt_fill(&mut self, color: BltPixel, dest: (usize, usize), dims: (usize, usize)) { let op = BltOp::VideoFill { color, dest, @@ -78,9 +86,8 @@ impl UefiFb<'_> { self.gop.blt(op).expect("Failed to fill screen with color"); } - // Draw directly to the frame buffer. - fn draw_fb(&mut self, index: usize, rgb: [u8; 3]) { + pub fn draw_fb(&mut self, index: usize, rgb: [u8; 3]) { let mi = self.gop.current_mode_info(); let mut fb = self.gop.frame_buffer();