Skip to main content

gstreamer_editing_services/auto/
formatter.rs

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#![allow(deprecated)]
6
7use crate::{Asset, Extractable, Timeline, ffi};
8use glib::{prelude::*, translate::*};
9
10glib::wrapper! {
11    /// Base class for timeline data serialization and deserialization.
12    ///
13    /// This is an Abstract Base Class, you cannot instantiate it.
14    ///
15    /// # Implements
16    ///
17    /// [`FormatterExt`][trait@crate::prelude::FormatterExt], [`trait@glib::ObjectExt`], [`ExtractableExt`][trait@crate::prelude::ExtractableExt], [`FormatterExtManual`][trait@crate::prelude::FormatterExtManual]
18    #[doc(alias = "GESFormatter")]
19    pub struct Formatter(Object<ffi::GESFormatter, ffi::GESFormatterClass>) @implements Extractable;
20
21    match fn {
22        type_ => || ffi::ges_formatter_get_type(),
23    }
24}
25
26impl Formatter {
27    pub const NONE: Option<&'static Formatter> = None;
28
29    /// Checks if there is a [`Formatter`][crate::Formatter] available which can load a [`Timeline`][crate::Timeline]
30    /// from the given URI.
31    /// ## `uri`
32    /// a `gchar` * pointing to the URI
33    ///
34    /// # Returns
35    ///
36    /// TRUE if there is a [`Formatter`][crate::Formatter] that can support the given uri
37    /// or FALSE if not.
38    #[doc(alias = "ges_formatter_can_load_uri")]
39    pub fn can_load_uri(uri: &str) -> Result<(), glib::Error> {
40        assert_initialized_main_thread!();
41        unsafe {
42            let mut error = std::ptr::null_mut();
43            let is_ok = ffi::ges_formatter_can_load_uri(uri.to_glib_none().0, &mut error);
44            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
45            if error.is_null() {
46                Ok(())
47            } else {
48                Err(from_glib_full(error))
49            }
50        }
51    }
52
53    /// Returns TRUE if there is a [`Formatter`][crate::Formatter] available which can save a
54    /// [`Timeline`][crate::Timeline] to the given URI.
55    /// ## `uri`
56    /// a `gchar` * pointing to a URI
57    ///
58    /// # Returns
59    ///
60    /// TRUE if the given `uri` is supported, else FALSE.
61    #[doc(alias = "ges_formatter_can_save_uri")]
62    pub fn can_save_uri(uri: &str) -> Result<(), glib::Error> {
63        assert_initialized_main_thread!();
64        unsafe {
65            let mut error = std::ptr::null_mut();
66            let is_ok = ffi::ges_formatter_can_save_uri(uri.to_glib_none().0, &mut error);
67            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
68            if error.is_null() {
69                Ok(())
70            } else {
71                Err(from_glib_full(error))
72            }
73        }
74    }
75
76    /// Get the default [`Asset`][crate::Asset] to use as formatter. It will return
77    /// the asset for the [`Formatter`][crate::Formatter] that has the highest `rank`
78    ///
79    /// # Deprecated since 1.30
80    ///
81    /// Use [`default_full()`][Self::default_full()] instead for MT-safety.
82    ///
83    /// # Returns
84    ///
85    /// The [`Asset`][crate::Asset] for the formatter with highest `rank`
86    #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
87    #[allow(deprecated)]
88    #[doc(alias = "ges_formatter_get_default")]
89    #[doc(alias = "get_default")]
90    #[allow(clippy::should_implement_trait)]
91    pub fn default() -> Asset {
92        assert_initialized_main_thread!();
93        unsafe { from_glib_none(ffi::ges_formatter_get_default()) }
94    }
95
96    /// Get the default [`Asset`][crate::Asset] to use as formatter. It will return
97    /// the asset for the [`Formatter`][crate::Formatter] that has the highest `rank`
98    ///
99    /// # Returns
100    ///
101    /// The [`Asset`][crate::Asset] for the formatter with highest `rank`
102    #[cfg(feature = "v1_30")]
103    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
104    #[doc(alias = "ges_formatter_get_default_full")]
105    #[doc(alias = "get_default_full")]
106    pub fn default_full() -> Asset {
107        assert_initialized_main_thread!();
108        unsafe { from_glib_full(ffi::ges_formatter_get_default_full()) }
109    }
110}
111
112/// Trait containing all [`struct@Formatter`] methods.
113///
114/// # Implementors
115///
116/// [`BaseXmlFormatter`][struct@crate::BaseXmlFormatter], [`CommandLineFormatter`][struct@crate::CommandLineFormatter], [`Formatter`][struct@crate::Formatter]
117pub trait FormatterExt: IsA<Formatter> + 'static {
118    /// Load data from the given URI into timeline.
119    ///
120    /// # Deprecated since 1.18
121    ///
122    /// Use [`TimelineExt::load_from_uri()`][crate::prelude::TimelineExt::load_from_uri()]
123    /// ## `timeline`
124    /// a [`Timeline`][crate::Timeline]
125    /// ## `uri`
126    /// a `gchar` * pointing to a URI
127    ///
128    /// # Returns
129    ///
130    /// TRUE if the timeline data was successfully loaded from the URI,
131    /// else FALSE.
132    #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
133    #[allow(deprecated)]
134    #[doc(alias = "ges_formatter_load_from_uri")]
135    fn load_from_uri(&self, timeline: &impl IsA<Timeline>, uri: &str) -> Result<(), glib::Error> {
136        unsafe {
137            let mut error = std::ptr::null_mut();
138            let is_ok = ffi::ges_formatter_load_from_uri(
139                self.as_ref().to_glib_none().0,
140                timeline.as_ref().to_glib_none().0,
141                uri.to_glib_none().0,
142                &mut error,
143            );
144            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
145            if error.is_null() {
146                Ok(())
147            } else {
148                Err(from_glib_full(error))
149            }
150        }
151    }
152
153    /// Save data from timeline to the given URI.
154    ///
155    /// # Deprecated since 1.18
156    ///
157    /// Use [`TimelineExt::save_to_uri()`][crate::prelude::TimelineExt::save_to_uri()]
158    /// ## `timeline`
159    /// a [`Timeline`][crate::Timeline]
160    /// ## `uri`
161    /// a `gchar` * pointing to a URI
162    /// ## `overwrite`
163    /// [`true`] to overwrite file if it exists
164    ///
165    /// # Returns
166    ///
167    /// TRUE if the timeline data was successfully saved to the URI
168    /// else FALSE.
169    #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
170    #[allow(deprecated)]
171    #[doc(alias = "ges_formatter_save_to_uri")]
172    fn save_to_uri(
173        &self,
174        timeline: &impl IsA<Timeline>,
175        uri: &str,
176        overwrite: bool,
177    ) -> Result<(), glib::Error> {
178        unsafe {
179            let mut error = std::ptr::null_mut();
180            let is_ok = ffi::ges_formatter_save_to_uri(
181                self.as_ref().to_glib_none().0,
182                timeline.as_ref().to_glib_none().0,
183                uri.to_glib_none().0,
184                overwrite.into_glib(),
185                &mut error,
186            );
187            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
188            if error.is_null() {
189                Ok(())
190            } else {
191                Err(from_glib_full(error))
192            }
193        }
194    }
195}
196
197impl<O: IsA<Formatter>> FormatterExt for O {}