1 | // This file was generated by gir (https://github.com/gtk-rs/gir) |
2 | // from gir-files (https://github.com/gtk-rs/gir-files) |
3 | // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) |
4 | // DO NOT EDIT |
5 | |
6 | use crate::{AllocationParams, Memory, Object}; |
7 | use glib::{prelude::*, translate::*}; |
8 | |
9 | glib::wrapper! { |
10 | #[doc (alias = "GstAllocator" )] |
11 | pub struct Allocator(Object<ffi::GstAllocator, ffi::GstAllocatorClass>) @extends Object; |
12 | |
13 | match fn { |
14 | type_ => || ffi::gst_allocator_get_type(), |
15 | } |
16 | } |
17 | |
18 | impl Allocator { |
19 | pub const NONE: Option<&'static Allocator> = None; |
20 | |
21 | #[doc (alias = "gst_allocator_find" )] |
22 | pub fn find(name: Option<&str>) -> Option<Allocator> { |
23 | assert_initialized_main_thread!(); |
24 | unsafe { from_glib_full(ptr:ffi::gst_allocator_find(name:name.to_glib_none().0)) } |
25 | } |
26 | } |
27 | |
28 | unsafe impl Send for Allocator {} |
29 | unsafe impl Sync for Allocator {} |
30 | |
31 | mod sealed { |
32 | pub trait Sealed {} |
33 | impl<T: super::IsA<super::Allocator>> Sealed for T {} |
34 | } |
35 | |
36 | pub trait AllocatorExt: IsA<Allocator> + sealed::Sealed + 'static { |
37 | #[doc (alias = "gst_allocator_alloc" )] |
38 | fn alloc( |
39 | &self, |
40 | size: usize, |
41 | params: Option<&AllocationParams>, |
42 | ) -> Result<Memory, glib::BoolError> { |
43 | unsafe { |
44 | Option::<_>::from_glib_full(ffi::gst_allocator_alloc( |
45 | self.as_ref().to_glib_none().0, |
46 | size, |
47 | mut_override(params.to_glib_none().0), |
48 | )) |
49 | .ok_or_else(|| glib::bool_error!("Failed to allocate memory" )) |
50 | } |
51 | } |
52 | |
53 | #[doc (alias = "gst_allocator_set_default" )] |
54 | fn set_default(self) { |
55 | unsafe { |
56 | ffi::gst_allocator_set_default(self.upcast().into_glib_ptr()); |
57 | } |
58 | } |
59 | } |
60 | |
61 | impl<O: IsA<Allocator>> AllocatorExt for O {} |
62 | |