diff options
Diffstat (limited to 'glfw/src/lib.rs')
| -rw-r--r-- | glfw/src/lib.rs | 53 | 
1 files changed, 0 insertions, 53 deletions
diff --git a/glfw/src/lib.rs b/glfw/src/lib.rs deleted file mode 100644 index f858766..0000000 --- a/glfw/src/lib.rs +++ /dev/null @@ -1,53 +0,0 @@ -#![deny(clippy::all, clippy::pedantic)] - -use std::ffi::{c_char, CStr}; -use std::ptr::null; - -mod ffi; -mod init; -mod util; - -pub mod window; - -pub use window::{Builder as WindowBuilder, Size as WindowSize, Window}; - -#[derive(Debug, thiserror::Error)] -pub enum Error -{ -    /// The current thread is not the main thread. -    #[error("The current thread is not the main thread")] -    NotInMainThread, - -    /// An internal nul byte was found in a window title. -    #[error("An internal nul byte was found in the window title")] -    InternalNulByteInWindowTitle, - -    #[error("This version of GLFW is unsupported")] -    UnsupportedVersion, - -    /// GLFW error. -    #[error("GLFW error {0} occured. {1}")] -    GlfwError(i32, String), -} - -fn get_glfw_error() -> Result<(), Error> -{ -    let mut description_ptr: *const c_char = null(); - -    let err = unsafe { crate::ffi::glfwGetError(&mut description_ptr) }; - -    if err == crate::ffi::GLFW_NO_ERROR { -        return Ok(()); -    } - -    // SAFETY: The description is guaranteed by GLFW to be valid UTF-8 -    let desc_str = unsafe { -        std::str::from_utf8_unchecked(CStr::from_ptr(description_ptr).to_bytes()) -    }; - -    // The description has to be copied because it is guaranteed to be valid only -    // until the next GLFW error occurs or the GLFW library is terminated. -    let description = desc_str.to_string(); - -    Err(Error::GlfwError(err, description)) -}  | 
