diff --git a/src/mpv.rs b/src/mpv.rs index 24a5adc..2d95500 100644 --- a/src/mpv.rs +++ b/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");