implement error for mpv error
This commit is contained in:
parent
4e2c992cc9
commit
45391b3da5
3 changed files with 24 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -221,6 +221,7 @@ dependencies = [
|
||||||
"base16ct",
|
"base16ct",
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"event-listener",
|
||||||
"gettext-rs",
|
"gettext-rs",
|
||||||
"glib-build-tools",
|
"glib-build-tools",
|
||||||
"gtk4",
|
"gtk4",
|
||||||
|
|
|
@ -8,6 +8,7 @@ adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
|
||||||
async-channel = "2.3.1"
|
async-channel = "2.3.1"
|
||||||
base16ct = { version = "0.2.0", features = ["std"] }
|
base16ct = { version = "0.2.0", features = ["std"] }
|
||||||
chrono = { version = "0.4.38", features = ["serde"] }
|
chrono = { version = "0.4.38", features = ["serde"] }
|
||||||
|
event-listener = "5.3.1"
|
||||||
gettext-rs = { version = "0.7.2", features = ["gettext-system"] }
|
gettext-rs = { version = "0.7.2", features = ["gettext-system"] }
|
||||||
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
|
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
|
||||||
md-5 = { version = "0.10.6", features = ["asm"] }
|
md-5 = { version = "0.10.6", features = ["asm"] }
|
||||||
|
|
25
src/mpv.rs
25
src/mpv.rs
|
@ -17,14 +17,33 @@ impl Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for Error {
|
use std::fmt;
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
|
||||||
|
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")
|
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()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for Error {}
|
||||||
|
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue