// Copyright (C) 2017 Sebastian Dröge // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use Bin; use Element; use glib; use glib::IsA; use glib::translate::{from_glib, ToGlibPtr}; use ffi; pub trait BinExtManual { fn add_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError>; fn remove_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError>; } impl> BinExtManual for O { fn add_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError> { for e in elements { unsafe { let ret: bool = from_glib(ffi::gst_bin_add(self.to_glib_none().0, e.to_glib_none().0)); if !ret { return Err(glib::BoolError("Failed to add elements")); } } } Ok(()) } fn remove_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError> { for e in elements { unsafe { let ret: bool = from_glib(ffi::gst_bin_remove( self.to_glib_none().0, e.to_glib_none().0, )); if !ret { return Err(glib::BoolError("Failed to add elements")); } } } Ok(()) } }