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::{ffi, Asset, Extractable, Timeline};
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]
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    /// # Returns
80    ///
81    /// The [`Asset`][crate::Asset] for the formatter with highest `rank`
82    #[doc(alias = "ges_formatter_get_default")]
83    #[doc(alias = "get_default")]
84    #[allow(clippy::should_implement_trait)]
85    pub fn default() -> Asset {
86        assert_initialized_main_thread!();
87        unsafe { from_glib_none(ffi::ges_formatter_get_default()) }
88    }
89}
90
91mod sealed {
92    pub trait Sealed {}
93    impl<T: super::IsA<super::Formatter>> Sealed for T {}
94}
95
96/// Trait containing all [`struct@Formatter`] methods.
97///
98/// # Implementors
99///
100/// [`BaseXmlFormatter`][struct@crate::BaseXmlFormatter], [`CommandLineFormatter`][struct@crate::CommandLineFormatter], [`Formatter`][struct@crate::Formatter]
101pub trait FormatterExt: IsA<Formatter> + sealed::Sealed + 'static {
102    /// Load data from the given URI into timeline.
103    ///
104    /// # Deprecated since 1.18
105    ///
106    /// Use [`TimelineExt::load_from_uri()`][crate::prelude::TimelineExt::load_from_uri()]
107    /// ## `timeline`
108    /// a [`Timeline`][crate::Timeline]
109    /// ## `uri`
110    /// a `gchar` * pointing to a URI
111    ///
112    /// # Returns
113    ///
114    /// TRUE if the timeline data was successfully loaded from the URI,
115    /// else FALSE.
116    #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
117    #[allow(deprecated)]
118    #[doc(alias = "ges_formatter_load_from_uri")]
119    fn load_from_uri(&self, timeline: &impl IsA<Timeline>, uri: &str) -> Result<(), glib::Error> {
120        unsafe {
121            let mut error = std::ptr::null_mut();
122            let is_ok = ffi::ges_formatter_load_from_uri(
123                self.as_ref().to_glib_none().0,
124                timeline.as_ref().to_glib_none().0,
125                uri.to_glib_none().0,
126                &mut error,
127            );
128            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
129            if error.is_null() {
130                Ok(())
131            } else {
132                Err(from_glib_full(error))
133            }
134        }
135    }
136
137    /// Save data from timeline to the given URI.
138    ///
139    /// # Deprecated since 1.18
140    ///
141    /// Use [`TimelineExt::save_to_uri()`][crate::prelude::TimelineExt::save_to_uri()]
142    /// ## `timeline`
143    /// a [`Timeline`][crate::Timeline]
144    /// ## `uri`
145    /// a `gchar` * pointing to a URI
146    /// ## `overwrite`
147    /// [`true`] to overwrite file if it exists
148    ///
149    /// # Returns
150    ///
151    /// TRUE if the timeline data was successfully saved to the URI
152    /// else FALSE.
153    #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
154    #[allow(deprecated)]
155    #[doc(alias = "ges_formatter_save_to_uri")]
156    fn save_to_uri(
157        &self,
158        timeline: &impl IsA<Timeline>,
159        uri: &str,
160        overwrite: bool,
161    ) -> Result<(), glib::Error> {
162        unsafe {
163            let mut error = std::ptr::null_mut();
164            let is_ok = ffi::ges_formatter_save_to_uri(
165                self.as_ref().to_glib_none().0,
166                timeline.as_ref().to_glib_none().0,
167                uri.to_glib_none().0,
168                overwrite.into_glib(),
169                &mut error,
170            );
171            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
172            if error.is_null() {
173                Ok(())
174            } else {
175                Err(from_glib_full(error))
176            }
177        }
178    }
179}
180
181impl<O: IsA<Formatter>> FormatterExt for O {}