From 95e8d05902eaea0d9ba980ce4e297519148ad0c4 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 20 Dec 2022 07:10:11 -0700 Subject: [PATCH] Rename SoftBufferError to SwBufError --- src/cg.rs | 4 ++-- src/error.rs | 6 +++--- src/lib.rs | 6 +++--- src/orbital.rs | 4 ++-- src/wayland.rs | 4 ++-- src/web.rs | 14 +++++++------- src/win32.rs | 6 +++--- src/x11.rs | 6 +++--- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cg.rs b/src/cg.rs index a64aa2e..276ca65 100644 --- a/src/cg.rs +++ b/src/cg.rs @@ -1,4 +1,4 @@ -use crate::{GraphicsContextImpl, SoftBufferError}; +use crate::{GraphicsContextImpl, SwBufError}; use raw_window_handle::{HasRawWindowHandle, AppKitWindowHandle}; use core_graphics::base::{kCGBitmapByteOrder32Little, kCGImageAlphaNoneSkipFirst, kCGRenderingIntentDefault}; use core_graphics::color_space::CGColorSpace; @@ -17,7 +17,7 @@ pub struct CGImpl { } impl CGImpl { - pub unsafe fn new(handle: AppKitWindowHandle) -> Result> { + pub unsafe fn new(handle: AppKitWindowHandle) -> Result> { let view = handle.ns_view as id; let layer = CALayer::new(); let subview: id = NSView::alloc(nil).initWithFrame_(view.frame()); diff --git a/src/error.rs b/src/error.rs index e692f4d..b77adb0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,7 +3,7 @@ use raw_window_handle::{HasRawWindowHandle, RawDisplayHandle, RawWindowHandle}; use thiserror::Error; #[derive(Error, Debug)] -pub enum SoftBufferError { +pub enum SwBufError { #[error( "The provided window returned an unsupported platform: {human_readable_window_platform_name}, {human_readable_display_platform_name}." )] @@ -19,9 +19,9 @@ pub enum SoftBufferError { } #[allow(unused)] // This isn't used on all platforms -pub(crate) fn unwrap(res: Result, str: &str) -> Result>{ +pub(crate) fn unwrap(res: Result, str: &str) -> Result>{ match res{ Ok(t) => Ok(t), - Err(e) => Err(SoftBufferError::PlatformError(Some(str.into()), Some(Box::new(e)))) + Err(e) => Err(SwBufError::PlatformError(Some(str.into()), Some(Box::new(e)))) } } \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 808c951..653592f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ mod orbital; mod error; -pub use error::SoftBufferError; +pub use error::SwBufError; use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle}; @@ -39,7 +39,7 @@ impl GraphicsContext { /// # Safety /// /// - Ensure that the passed object is valid to draw a 2D buffer to - pub unsafe fn new(window: W) -> Result> { + pub unsafe fn new(window: W) -> Result> { let raw_window_handle = window.raw_window_handle(); let raw_display_handle = window.raw_display_handle(); @@ -56,7 +56,7 @@ impl GraphicsContext { (RawWindowHandle::Web(web_handle), _) => Box::new(web::WebImpl::new(web_handle)?), #[cfg(target_os = "redox")] (RawWindowHandle::Orbital(orbital_handle), _) => Box::new(orbital::OrbitalImpl::new(orbital_handle)?), - (unimplemented_window_handle, unimplemented_display_handle) => return Err(SoftBufferError::UnsupportedPlatform { + (unimplemented_window_handle, unimplemented_display_handle) => return Err(SwBufError::UnsupportedPlatform { window, human_readable_window_platform_name: window_handle_type_name(&unimplemented_window_handle), human_readable_display_platform_name: display_handle_type_name(&unimplemented_display_handle), diff --git a/src/orbital.rs b/src/orbital.rs index 76cbdb6..48e7122 100644 --- a/src/orbital.rs +++ b/src/orbital.rs @@ -7,7 +7,7 @@ use std::{ }; use crate::GraphicsContextImpl; -use crate::SoftBufferError; +use crate::SwBufError; struct OrbitalMap { address: usize, @@ -47,7 +47,7 @@ pub struct OrbitalImpl { } impl OrbitalImpl { - pub fn new(handle: OrbitalWindowHandle) -> Result> { + pub fn new(handle: OrbitalWindowHandle) -> Result> { Ok(Self { handle }) } } diff --git a/src/wayland.rs b/src/wayland.rs index 32890b5..a494c58 100644 --- a/src/wayland.rs +++ b/src/wayland.rs @@ -1,4 +1,4 @@ -use crate::{error::unwrap, GraphicsContextImpl, SoftBufferError}; +use crate::{error::unwrap, GraphicsContextImpl, SwBufError}; use nix::sys::memfd::{memfd_create, MemFdCreateFlag}; use raw_window_handle::{HasRawWindowHandle, WaylandDisplayHandle, WaylandWindowHandle}; use std::{ @@ -43,7 +43,7 @@ impl WaylandImpl { pub unsafe fn new( window_handle: WaylandWindowHandle, display_handle: WaylandDisplayHandle, - ) -> Result> { + ) -> Result> { let conn = Connection::from_backend(Backend::from_foreign_display( display_handle.display as *mut _, )); diff --git a/src/web.rs b/src/web.rs index e20fa5e..423b5b0 100644 --- a/src/web.rs +++ b/src/web.rs @@ -7,7 +7,7 @@ use web_sys::HtmlCanvasElement; use web_sys::ImageData; use crate::GraphicsContextImpl; -use crate::SoftBufferError; +use crate::SwBufError; pub struct WebImpl { canvas: HtmlCanvasElement, @@ -15,17 +15,17 @@ pub struct WebImpl { } impl WebImpl { - pub fn new(handle: WebWindowHandle) -> Result> { + pub fn new(handle: WebWindowHandle) -> Result> { let canvas: HtmlCanvasElement = web_sys::window() .ok_or_else(|| { - SoftBufferError::PlatformError( + SwBufError::PlatformError( Some("`window` is not present in this runtime".into()), None, ) })? .document() .ok_or_else(|| { - SoftBufferError::PlatformError( + SwBufError::PlatformError( Some("`document` is not present in this runtime".into()), None, ) @@ -34,7 +34,7 @@ impl WebImpl { // `querySelector` only throws an error if the selector is invalid. .unwrap() .ok_or_else(|| { - SoftBufferError::PlatformError( + SwBufError::PlatformError( Some("No canvas found with the given id".into()), None, ) @@ -45,13 +45,13 @@ impl WebImpl { let ctx = canvas .get_context("2d") .map_err(|_| { - SoftBufferError::PlatformError( + SwBufError::PlatformError( Some("Canvas already controlled using `OffscreenCanvas`".into()), None, ) })? .ok_or_else(|| { - SoftBufferError::PlatformError( + SwBufError::PlatformError( Some("A canvas context other than `CanvasRenderingContext2d` was already created".into()), None, ) diff --git a/src/win32.rs b/src/win32.rs index f117624..0517844 100644 --- a/src/win32.rs +++ b/src/win32.rs @@ -1,4 +1,4 @@ -use crate::{GraphicsContextImpl, SoftBufferError}; +use crate::{GraphicsContextImpl, SwBufError}; use raw_window_handle::{HasRawWindowHandle, Win32WindowHandle}; use std::os::raw::c_int; use winapi::shared::windef::{HDC, HWND}; @@ -19,11 +19,11 @@ struct BitmapInfo { } impl Win32Impl { - pub unsafe fn new(handle: &Win32WindowHandle) -> Result> { + pub unsafe fn new(handle: &Win32WindowHandle) -> Result> { let dc = GetDC(handle.hwnd as HWND); if dc.is_null(){ - return Err(SoftBufferError::PlatformError(Some("Device Context is null".into()), None)); + return Err(SwBufError::PlatformError(Some("Device Context is null".into()), None)); } Ok( diff --git a/src/x11.rs b/src/x11.rs index 6515cf2..8cd6ff0 100644 --- a/src/x11.rs +++ b/src/x11.rs @@ -1,4 +1,4 @@ -use crate::{GraphicsContextImpl, SoftBufferError}; +use crate::{GraphicsContextImpl, SwBufError}; use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, XlibDisplayHandle, XlibWindowHandle}; use std::os::raw::{c_char, c_uint}; use x11_dl::xlib::{Display, Visual, Xlib, ZPixmap, GC}; @@ -13,10 +13,10 @@ pub struct X11Impl { } impl X11Impl { - pub unsafe fn new(window_handle: XlibWindowHandle, display_handle: XlibDisplayHandle) -> Result> { + pub unsafe fn new(window_handle: XlibWindowHandle, display_handle: XlibDisplayHandle) -> Result> { let lib = match Xlib::open() { Ok(lib) => lib, - Err(e) => return Err(SoftBufferError::PlatformError(Some("Failed to open Xlib".into()), Some(Box::new(e)))) + Err(e) => return Err(SwBufError::PlatformError(Some("Failed to open Xlib".into()), Some(Box::new(e)))) }; let screen = (lib.XDefaultScreen)(display_handle.display as *mut Display); let gc = (lib.XDefaultGC)(display_handle.display as *mut Display, screen);