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