forked from mirrors/gstreamer-rs
Add the has_name() fn to EventRef, MessageRef and StructureRef
They are handy and they match the C api
This commit is contained in:
parent
9bf5f641ff
commit
97f59d34fa
3 changed files with 15 additions and 0 deletions
|
@ -216,6 +216,11 @@ impl EventRef {
|
|||
unsafe { from_glib((*self.as_ptr()).type_) }
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_event_has_name")]
|
||||
pub fn has_name(&self, name: &str) -> bool {
|
||||
self.structure().map_or(false, |s| s.has_name(name))
|
||||
}
|
||||
|
||||
pub fn view(&self) -> EventView<&EventRef> {
|
||||
let type_ = unsafe { (*self.as_ptr()).type_ };
|
||||
|
||||
|
|
|
@ -68,6 +68,11 @@ impl MessageRef {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_message_has_name")]
|
||||
pub fn has_name(&self, name: &str) -> bool {
|
||||
self.structure().map_or(false, |s| s.has_name(name))
|
||||
}
|
||||
|
||||
pub fn view(&self) -> MessageView {
|
||||
let type_ = unsafe { (*self.as_ptr()).type_ };
|
||||
|
||||
|
|
|
@ -495,6 +495,11 @@ impl StructureRef {
|
|||
unsafe { ffi::gst_structure_set_name(&mut self.0, name.to_glib_none().0) }
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_structure_has_name")]
|
||||
pub fn has_name(&self, name: &str) -> bool {
|
||||
self.name() == name
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_structure_has_field")]
|
||||
pub fn has_field(&self, field: &str) -> bool {
|
||||
unsafe {
|
||||
|
|
Loading…
Reference in a new issue