Skip to content

Commit 95e8d05

Browse files
committed
Rename SoftBufferError to SwBufError
1 parent 33fe3ae commit 95e8d05

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

src/cg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{GraphicsContextImpl, SoftBufferError};
1+
use crate::{GraphicsContextImpl, SwBufError};
22
use raw_window_handle::{HasRawWindowHandle, AppKitWindowHandle};
33
use core_graphics::base::{kCGBitmapByteOrder32Little, kCGImageAlphaNoneSkipFirst, kCGRenderingIntentDefault};
44
use core_graphics::color_space::CGColorSpace;
@@ -17,7 +17,7 @@ pub struct CGImpl {
1717
}
1818

1919
impl CGImpl {
20-
pub unsafe fn new<W: HasRawWindowHandle>(handle: AppKitWindowHandle) -> Result<Self, SoftBufferError<W>> {
20+
pub unsafe fn new<W: HasRawWindowHandle>(handle: AppKitWindowHandle) -> Result<Self, SwBufError<W>> {
2121
let view = handle.ns_view as id;
2222
let layer = CALayer::new();
2323
let subview: id = NSView::alloc(nil).initWithFrame_(view.frame());

src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use raw_window_handle::{HasRawWindowHandle, RawDisplayHandle, RawWindowHandle};
33
use thiserror::Error;
44

55
#[derive(Error, Debug)]
6-
pub enum SoftBufferError<W: HasRawWindowHandle> {
6+
pub enum SwBufError<W: HasRawWindowHandle> {
77
#[error(
88
"The provided window returned an unsupported platform: {human_readable_window_platform_name}, {human_readable_display_platform_name}."
99
)]
@@ -19,9 +19,9 @@ pub enum SoftBufferError<W: HasRawWindowHandle> {
1919
}
2020

2121
#[allow(unused)] // This isn't used on all platforms
22-
pub(crate) fn unwrap<T, E: std::error::Error + 'static, W: HasRawWindowHandle>(res: Result<T, E>, str: &str) -> Result<T, SoftBufferError<W>>{
22+
pub(crate) fn unwrap<T, E: std::error::Error + 'static, W: HasRawWindowHandle>(res: Result<T, E>, str: &str) -> Result<T, SwBufError<W>>{
2323
match res{
2424
Ok(t) => Ok(t),
25-
Err(e) => Err(SoftBufferError::PlatformError(Some(str.into()), Some(Box::new(e))))
25+
Err(e) => Err(SwBufError::PlatformError(Some(str.into()), Some(Box::new(e))))
2626
}
2727
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod orbital;
2020

2121
mod error;
2222

23-
pub use error::SoftBufferError;
23+
pub use error::SwBufError;
2424

2525
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle};
2626

@@ -39,7 +39,7 @@ impl<W: HasRawWindowHandle + HasRawDisplayHandle> GraphicsContext<W> {
3939
/// # Safety
4040
///
4141
/// - Ensure that the passed object is valid to draw a 2D buffer to
42-
pub unsafe fn new(window: W) -> Result<Self, SoftBufferError<W>> {
42+
pub unsafe fn new(window: W) -> Result<Self, SwBufError<W>> {
4343
let raw_window_handle = window.raw_window_handle();
4444
let raw_display_handle = window.raw_display_handle();
4545

@@ -56,7 +56,7 @@ impl<W: HasRawWindowHandle + HasRawDisplayHandle> GraphicsContext<W> {
5656
(RawWindowHandle::Web(web_handle), _) => Box::new(web::WebImpl::new(web_handle)?),
5757
#[cfg(target_os = "redox")]
5858
(RawWindowHandle::Orbital(orbital_handle), _) => Box::new(orbital::OrbitalImpl::new(orbital_handle)?),
59-
(unimplemented_window_handle, unimplemented_display_handle) => return Err(SoftBufferError::UnsupportedPlatform {
59+
(unimplemented_window_handle, unimplemented_display_handle) => return Err(SwBufError::UnsupportedPlatform {
6060
window,
6161
human_readable_window_platform_name: window_handle_type_name(&unimplemented_window_handle),
6262
human_readable_display_platform_name: display_handle_type_name(&unimplemented_display_handle),

src/orbital.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
};
88

99
use crate::GraphicsContextImpl;
10-
use crate::SoftBufferError;
10+
use crate::SwBufError;
1111

1212
struct OrbitalMap {
1313
address: usize,
@@ -47,7 +47,7 @@ pub struct OrbitalImpl {
4747
}
4848

4949
impl OrbitalImpl {
50-
pub fn new<W: HasRawWindowHandle>(handle: OrbitalWindowHandle) -> Result<Self, SoftBufferError<W>> {
50+
pub fn new<W: HasRawWindowHandle>(handle: OrbitalWindowHandle) -> Result<Self, SwBufError<W>> {
5151
Ok(Self { handle })
5252
}
5353
}

src/wayland.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{error::unwrap, GraphicsContextImpl, SoftBufferError};
1+
use crate::{error::unwrap, GraphicsContextImpl, SwBufError};
22
use nix::sys::memfd::{memfd_create, MemFdCreateFlag};
33
use raw_window_handle::{HasRawWindowHandle, WaylandDisplayHandle, WaylandWindowHandle};
44
use std::{
@@ -43,7 +43,7 @@ impl WaylandImpl {
4343
pub unsafe fn new<W: HasRawWindowHandle>(
4444
window_handle: WaylandWindowHandle,
4545
display_handle: WaylandDisplayHandle,
46-
) -> Result<Self, SoftBufferError<W>> {
46+
) -> Result<Self, SwBufError<W>> {
4747
let conn = Connection::from_backend(Backend::from_foreign_display(
4848
display_handle.display as *mut _,
4949
));

src/web.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ use web_sys::HtmlCanvasElement;
77
use web_sys::ImageData;
88

99
use crate::GraphicsContextImpl;
10-
use crate::SoftBufferError;
10+
use crate::SwBufError;
1111

1212
pub struct WebImpl {
1313
canvas: HtmlCanvasElement,
1414
ctx: CanvasRenderingContext2d,
1515
}
1616

1717
impl WebImpl {
18-
pub fn new<W: HasRawWindowHandle>(handle: WebWindowHandle) -> Result<Self, SoftBufferError<W>> {
18+
pub fn new<W: HasRawWindowHandle>(handle: WebWindowHandle) -> Result<Self, SwBufError<W>> {
1919
let canvas: HtmlCanvasElement = web_sys::window()
2020
.ok_or_else(|| {
21-
SoftBufferError::PlatformError(
21+
SwBufError::PlatformError(
2222
Some("`window` is not present in this runtime".into()),
2323
None,
2424
)
2525
})?
2626
.document()
2727
.ok_or_else(|| {
28-
SoftBufferError::PlatformError(
28+
SwBufError::PlatformError(
2929
Some("`document` is not present in this runtime".into()),
3030
None,
3131
)
@@ -34,7 +34,7 @@ impl WebImpl {
3434
// `querySelector` only throws an error if the selector is invalid.
3535
.unwrap()
3636
.ok_or_else(|| {
37-
SoftBufferError::PlatformError(
37+
SwBufError::PlatformError(
3838
Some("No canvas found with the given id".into()),
3939
None,
4040
)
@@ -45,13 +45,13 @@ impl WebImpl {
4545
let ctx = canvas
4646
.get_context("2d")
4747
.map_err(|_| {
48-
SoftBufferError::PlatformError(
48+
SwBufError::PlatformError(
4949
Some("Canvas already controlled using `OffscreenCanvas`".into()),
5050
None,
5151
)
5252
})?
5353
.ok_or_else(|| {
54-
SoftBufferError::PlatformError(
54+
SwBufError::PlatformError(
5555
Some("A canvas context other than `CanvasRenderingContext2d` was already created".into()),
5656
None,
5757
)

src/win32.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{GraphicsContextImpl, SoftBufferError};
1+
use crate::{GraphicsContextImpl, SwBufError};
22
use raw_window_handle::{HasRawWindowHandle, Win32WindowHandle};
33
use std::os::raw::c_int;
44
use winapi::shared::windef::{HDC, HWND};
@@ -19,11 +19,11 @@ struct BitmapInfo {
1919
}
2020

2121
impl Win32Impl {
22-
pub unsafe fn new<W: HasRawWindowHandle>(handle: &Win32WindowHandle) -> Result<Self, crate::SoftBufferError<W>> {
22+
pub unsafe fn new<W: HasRawWindowHandle>(handle: &Win32WindowHandle) -> Result<Self, crate::SwBufError<W>> {
2323
let dc = GetDC(handle.hwnd as HWND);
2424

2525
if dc.is_null(){
26-
return Err(SoftBufferError::PlatformError(Some("Device Context is null".into()), None));
26+
return Err(SwBufError::PlatformError(Some("Device Context is null".into()), None));
2727
}
2828

2929
Ok(

src/x11.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{GraphicsContextImpl, SoftBufferError};
1+
use crate::{GraphicsContextImpl, SwBufError};
22
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, XlibDisplayHandle, XlibWindowHandle};
33
use std::os::raw::{c_char, c_uint};
44
use x11_dl::xlib::{Display, Visual, Xlib, ZPixmap, GC};
@@ -13,10 +13,10 @@ pub struct X11Impl {
1313
}
1414

1515
impl X11Impl {
16-
pub unsafe fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(window_handle: XlibWindowHandle, display_handle: XlibDisplayHandle) -> Result<Self, SoftBufferError<W>> {
16+
pub unsafe fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(window_handle: XlibWindowHandle, display_handle: XlibDisplayHandle) -> Result<Self, SwBufError<W>> {
1717
let lib = match Xlib::open() {
1818
Ok(lib) => lib,
19-
Err(e) => return Err(SoftBufferError::PlatformError(Some("Failed to open Xlib".into()), Some(Box::new(e))))
19+
Err(e) => return Err(SwBufError::PlatformError(Some("Failed to open Xlib".into()), Some(Box::new(e))))
2020
};
2121
let screen = (lib.XDefaultScreen)(display_handle.display as *mut Display);
2222
let gc = (lib.XDefaultGC)(display_handle.display as *mut Display, screen);

0 commit comments

Comments
 (0)