Commit 4c5aa49f authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Run manual code through rustfmt

parent abe4248a
......@@ -75,7 +75,10 @@ fn main() {
}
});
assert_ne!(pipeline.set_state(gst::State::Playing), gst::StateChangeReturn::Failure);
assert_ne!(
pipeline.set_state(gst::State::Playing),
gst::StateChangeReturn::Failure
);
let bus = pipeline.get_bus().unwrap();
......@@ -88,17 +91,29 @@ fn main() {
match msg.view() {
MessageView::Eos => break,
MessageView::Error(err) => {
println!("Error from {}: {} ({:?})", msg.get_src().get_path_string(),
err.get_error(), err.get_debug());
println!(
"Error from {}: {} ({:?})",
msg.get_src().get_path_string(),
err.get_error(),
err.get_debug()
);
break;
},
}
MessageView::StateChanged(s) => {
println!("State changed from {}: {:?} -> {:?} ({:?})", msg.get_src().get_path_string(),
s.get_old(), s.get_current(), s.get_pending());
},
println!(
"State changed from {}: {:?} -> {:?} ({:?})",
msg.get_src().get_path_string(),
s.get_old(),
s.get_current(),
s.get_pending()
);
}
_ => (),
}
}
assert_ne!(pipeline.set_state(gst::State::Null), gst::StateChangeReturn::Failure);
assert_ne!(
pipeline.set_state(gst::State::Null),
gst::StateChangeReturn::Failure
);
}
......@@ -21,10 +21,14 @@ fn main() {
match msg.view() {
MessageView::Eos => break,
MessageView::Error(err) => {
println!("Error from {}: {} ({:?})", msg.get_src().get_path_string(),
err.get_error(), err.get_debug());
println!(
"Error from {}: {} ({:?})",
msg.get_src().get_path_string(),
err.get_error(),
err.get_debug()
);
break;
},
}
_ => (),
}
}
......
......@@ -19,16 +19,18 @@ fn main() {
assert_ne!(ret, gst::StateChangeReturn::Failure);
bus.add_signal_watch();
bus.connect_message(|_, msg| {
match msg.view() {
MessageView::Eos => gtk::main_quit(),
MessageView::Error(err) => {
println!("Error from {}: {} ({:?})", msg.get_src().get_path_string(),
err.get_error(), err.get_debug());
gtk::main_quit();
},
_ => (),
bus.connect_message(|_, msg| match msg.view() {
MessageView::Eos => gtk::main_quit(),
MessageView::Error(err) => {
println!(
"Error from {}: {} ({:?})",
msg.get_src().get_path_string(),
err.get_error(),
err.get_debug()
);
gtk::main_quit();
}
_ => (),
});
gtk::main();
......
......@@ -24,7 +24,8 @@ impl<O: IsA<Bin>> BinExtManual for O {
fn add_many<E: IsA<Element>>(&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));
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"));
}
......@@ -37,7 +38,10 @@ impl<O: IsA<Bin>> BinExtManual for O {
fn remove_many<E: IsA<Element>>(&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));
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"));
}
......
......@@ -65,15 +65,17 @@ impl CapsRef {
pub fn set_simple(&mut self, values: &[(&str, &glib::Value)]) {
for &(name, ref value) in values {
unsafe {
ffi::gst_caps_set_value(self.as_mut_ptr(), name.to_glib_none().0, value.to_glib_none().0);
ffi::gst_caps_set_value(
self.as_mut_ptr(),
name.to_glib_none().0,
value.to_glib_none().0,
);
}
}
}
pub fn to_string(&self) -> String {
unsafe {
from_glib_full(ffi::gst_caps_to_string(self.as_ptr()))
}
unsafe { from_glib_full(ffi::gst_caps_to_string(self.as_ptr())) }
}
pub fn get_structure(&self, idx: u32) -> Option<&StructureRef> {
......@@ -103,9 +105,7 @@ impl CapsRef {
}
pub fn append_structure(&mut self, structure: Structure) {
unsafe {
ffi::gst_caps_append_structure(self.as_mut_ptr(), structure.into_ptr())
}
unsafe { ffi::gst_caps_append_structure(self.as_mut_ptr(), structure.into_ptr()) }
}
pub fn get_size(&self) -> u32 {
......@@ -125,9 +125,7 @@ impl CapsRef {
impl glib::types::StaticType for GstRc<CapsRef> {
fn static_type() -> glib::types::Type {
unsafe {
from_glib(ffi::gst_caps_get_type())
}
unsafe { from_glib(ffi::gst_caps_get_type()) }
}
}
......
......@@ -18,7 +18,10 @@ impl Element {
pub fn link_many<E: IsA<Element>>(elements: &[&E]) -> Result<(), glib::BoolError> {
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
unsafe {
let ret: bool = from_glib(ffi::gst_element_link(e1.to_glib_none().0, e2.to_glib_none().0));
let ret: bool = from_glib(ffi::gst_element_link(
e1.to_glib_none().0,
e2.to_glib_none().0,
));
if !ret {
return Err(glib::BoolError("Failed to link elements"));
}
......
......@@ -36,17 +36,7 @@ macro_rules! skip_assert_initialized {
)
}
pub use glib::{
Cast,
Continue,
Error,
IsA,
StaticType,
ToValue,
Type,
TypedValue,
Value,
};
pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue, Value};
mod auto;
pub use auto::*;
......@@ -72,7 +62,11 @@ use std::ptr;
pub fn init() -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
if from_glib(ffi::gst_init_check(ptr::null_mut(), ptr::null_mut(), &mut error)) {
if from_glib(ffi::gst_init_check(
ptr::null_mut(),
ptr::null_mut(),
&mut error,
)) {
Ok(())
} else {
Err(from_glib_full(error))
......
This diff is collapsed.
......@@ -12,7 +12,8 @@ use std::marker::PhantomData;
use ffi;
use glib;
use glib::translate::{from_glib, Stash, StashMut, ToGlibPtr, ToGlibPtrMut, FromGlibPtrNone, FromGlibPtrFull, FromGlibPtrBorrow};
use glib::translate::{from_glib, Stash, StashMut, ToGlibPtr, ToGlibPtrMut, FromGlibPtrNone,
FromGlibPtrFull, FromGlibPtrBorrow};
#[derive(Hash, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct GstRc<T: MiniObject> {
......@@ -60,11 +61,9 @@ impl<T: MiniObject> GstRc<T> {
return &mut *self.obj;
}
self.obj = T::from_mut_ptr(
ffi::gst_mini_object_make_writable(
self.as_mut_ptr() as *mut ffi::GstMiniObject
) as *mut T::GstType
);
self.obj = T::from_mut_ptr(ffi::gst_mini_object_make_writable(
self.as_mut_ptr() as *mut ffi::GstMiniObject,
) as *mut T::GstType);
assert!(self.is_writable());
&mut *self.obj
......@@ -81,17 +80,17 @@ impl<T: MiniObject> GstRc<T> {
pub fn copy(&self) -> Self {
unsafe {
GstRc::from_glib_full(
ffi::gst_mini_object_copy(
self.as_ptr() as *const ffi::GstMiniObject
) as *const T::GstType
)
GstRc::from_glib_full(ffi::gst_mini_object_copy(
self.as_ptr() as *const ffi::GstMiniObject,
) as *const T::GstType)
}
}
pub fn is_writable(&self) -> bool {
unsafe {
from_glib(ffi::gst_mini_object_is_writable(self.as_ptr() as *const ffi::GstMiniObject))
from_glib(ffi::gst_mini_object_is_writable(
self.as_ptr() as *const ffi::GstMiniObject,
))
}
}
......@@ -255,4 +254,3 @@ impl<T: MiniObject + 'static> FromGlibPtrBorrow<*mut T::GstType> for GstRc<T> {
Self::from_glib_borrow(ptr)
}
}
......@@ -15,7 +15,8 @@ use std::borrow::{Borrow, ToOwned, BorrowMut};
use std::marker::PhantomData;
use glib;
use glib::translate::{from_glib, from_glib_full, from_glib_none, Stash, StashMut, ToGlibPtr, ToGlibPtrMut, FromGlibPtrNone, FromGlibPtrBorrow, FromGlibPtrFull};
use glib::translate::{from_glib, from_glib_full, from_glib_none, Stash, StashMut, ToGlibPtr,
ToGlibPtrMut, FromGlibPtrNone, FromGlibPtrBorrow, FromGlibPtrFull};
use glib::value::{Value, ToValue, FromValueOptional};
use ffi;
use glib_ffi;
......@@ -148,9 +149,7 @@ impl ToOwned for StructureRef {
impl glib::types::StaticType for Structure {
fn static_type() -> glib::types::Type {
unsafe {
from_glib(ffi::gst_structure_get_type())
}
unsafe { from_glib(ffi::gst_structure_get_type()) }
}
}
......@@ -162,9 +161,7 @@ impl<'a> ToGlibPtr<'a, *const ffi::GstStructure> for Structure {
}
fn to_glib_full(&self) -> *const ffi::GstStructure {
unsafe {
ffi::gst_structure_copy(&(*self.0).0)
}
unsafe { ffi::gst_structure_copy(&(*self.0).0) }
}
}
......@@ -176,9 +173,7 @@ impl<'a> ToGlibPtr<'a, *mut ffi::GstStructure> for Structure {
}
fn to_glib_full(&self) -> *mut ffi::GstStructure {
unsafe {
ffi::gst_structure_copy(&(*self.0).0)
}
unsafe { ffi::gst_structure_copy(&(*self.0).0) }
}
}
......@@ -210,19 +205,13 @@ impl FromGlibPtrNone<*mut ffi::GstStructure> for Structure {
impl FromGlibPtrFull<*const ffi::GstStructure> for Structure {
unsafe fn from_glib_full(ptr: *const ffi::GstStructure) -> Self {
Structure(
ptr as *mut StructureRef,
PhantomData,
)
Structure(ptr as *mut StructureRef, PhantomData)
}
}
impl FromGlibPtrFull<*mut ffi::GstStructure> for Structure {
unsafe fn from_glib_full(ptr: *mut ffi::GstStructure) -> Self {
Structure(
ptr as *mut StructureRef,
PhantomData,
)
Structure(ptr as *mut StructureRef, PhantomData)
}
}
......@@ -243,9 +232,7 @@ impl StructureRef {
}
pub fn to_string(&self) -> String {
unsafe {
from_glib_full(ffi::gst_structure_to_string(&self.0))
}
unsafe { from_glib_full(ffi::gst_structure_to_string(&self.0)) }
}
pub fn get<'a, T: FromValueOptional<'a>>(&'a self, name: &str) -> Option<T> {
......@@ -271,20 +258,29 @@ impl StructureRef {
pub fn set_value(&mut self, name: &str, mut value: Value) {
unsafe {
ffi::gst_structure_take_value(&mut self.0, name.to_glib_none().0, value.to_glib_none_mut().0);
ffi::gst_structure_take_value(
&mut self.0,
name.to_glib_none().0,
value.to_glib_none_mut().0,
);
mem::forget(value);
}
}
pub fn get_name(&self) -> &str {
unsafe {
CStr::from_ptr(ffi::gst_structure_get_name(&self.0)).to_str().unwrap()
CStr::from_ptr(ffi::gst_structure_get_name(&self.0))
.to_str()
.unwrap()
}
}
pub fn has_field(&self, field: &str) -> bool {
unsafe {
from_glib(ffi::gst_structure_has_field(&self.0, field.to_glib_none().0))
from_glib(ffi::gst_structure_has_field(
&self.0,
field.to_glib_none().0,
))
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment