impl debug for mpv handle
This commit is contained in:
parent
f8d139e36f
commit
070f25f862
1 changed files with 16 additions and 0 deletions
16
src/mpv.rs
16
src/mpv.rs
|
@ -66,6 +66,12 @@ impl Default for Handle {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Handle {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
f.debug_tuple("Handle").field(&self.client_name()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl Handle {
|
||||
pub fn new() -> Self {
|
||||
let inner =
|
||||
|
@ -104,6 +110,16 @@ impl Handle {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn client_name(&self) -> &str {
|
||||
unsafe { CStr::from_ptr(ffi::mpv_client_name(self.inner.as_ptr())) }
|
||||
.to_str()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn client_id(&self) -> i64 {
|
||||
unsafe { ffi::mpv_client_id(self.inner.as_ptr()) }
|
||||
}
|
||||
|
||||
pub fn set_property(&self, name: &str, value: impl FormatValue) -> Result<(), Error> {
|
||||
// need to add zero terminator
|
||||
let name = CString::new(name).expect("null bytes in property name");
|
||||
|
|
Loading…
Reference in a new issue