summary refs log tree commit diff
path: root/gpu_display/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'gpu_display/src/lib.rs')
-rw-r--r--gpu_display/src/lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/gpu_display/src/lib.rs b/gpu_display/src/lib.rs
index 6b93bbc..01cef5e 100644
--- a/gpu_display/src/lib.rs
+++ b/gpu_display/src/lib.rs
@@ -12,6 +12,7 @@ mod dwl;
 use std::cell::Cell;
 use std::collections::HashMap;
 use std::ffi::{CStr, CString};
+use std::fmt::{self, Display};
 use std::os::unix::io::{AsRawFd, RawFd};
 use std::path::Path;
 use std::ptr::null_mut;
@@ -45,6 +46,23 @@ pub enum GpuDisplayError {
     InvalidPath,
 }
 
+impl Display for GpuDisplayError {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        use self::GpuDisplayError::*;
+
+        match self {
+            Allocate => write!(f, "internal allocation failed"),
+            Connect => write!(f, "failed to connect to compositor"),
+            CreateShm(e) => write!(f, "failed to create shared memory: {}", e),
+            SetSize(e) => write!(f, "failed to set size of shared memory: {}", e),
+            CreateSurface => write!(f, "failed to crate surface on the compositor"),
+            FailedImport => write!(f, "failed to import a buffer to the compositor"),
+            InvalidSurfaceId => write!(f, "invalid surface ID"),
+            InvalidPath => write!(f, "invalid path"),
+        }
+    }
+}
+
 struct DwlContext(*mut dwl_context);
 impl Drop for DwlContext {
     fn drop(&mut self) {