diff --git a/Cargo.lock b/Cargo.lock index f0549b6..6cf48e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,6 +221,7 @@ dependencies = [ "base16ct", "bindgen", "chrono", + "event-listener", "gettext-rs", "glib-build-tools", "gtk4", diff --git a/Cargo.toml b/Cargo.toml index 6f8d18f..22bf015 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] } async-channel = "2.3.1" base16ct = { version = "0.2.0", features = ["std"] } chrono = { version = "0.4.38", features = ["serde"] } +event-listener = "5.3.1" gettext-rs = { version = "0.7.2", features = ["gettext-system"] } gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] } md-5 = { version = "0.10.6", features = ["asm"] } diff --git a/src/mpv.rs b/src/mpv.rs index bd8ff30..e59e847 100644 --- a/src/mpv.rs +++ b/src/mpv.rs @@ -17,14 +17,33 @@ impl Error { } } -impl std::fmt::Debug for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { +use std::fmt; + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { + fmt::Display::fmt( + unsafe { &CStr::from_ptr(ffi::mpv_error_string(self.0 as c_int)) } + .to_str() + .unwrap(), + f, + ) + } +} + +impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { f.debug_tuple("Error") - .field(unsafe { &CStr::from_ptr(ffi::mpv_error_string(self.0 as c_int)) }) + .field( + &unsafe { &CStr::from_ptr(ffi::mpv_error_string(self.0 as c_int)) } + .to_str() + .unwrap(), + ) .finish() } } +impl std::error::Error for Error {} + use std::pin::Pin; use std::ptr::NonNull;