1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::Asset;
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// A [`glib::Object`][crate::glib::Object] that implements the [`Extractable`][crate::Extractable] interface can be
    /// extracted from a [`Asset`][crate::Asset] using [`AssetExt::extract()`][crate::prelude::AssetExt::extract()].
    ///
    /// Each extractable type will have its own way of interpreting the
    /// [`id`][struct@crate::Asset#id] of an asset (or, if it is associated with a specific
    /// subclass of [`Asset`][crate::Asset], the asset subclass may handle the
    /// interpretation of the [`id`][struct@crate::Asset#id]). By default, the requested asset
    /// [`id`][struct@crate::Asset#id] will be ignored by a [`Extractable`][crate::Extractable] and will be set to
    /// the type name of the extractable instead. Also by default, when the
    /// requested asset is extracted, the returned object will simply be a
    /// newly created default object of that extractable type. You should check
    /// the documentation for each extractable type to see if they differ from
    /// the default.
    ///
    /// After the object is extracted, it will have a reference to the asset it
    /// came from, which you can retrieve using [`ExtractableExt::asset()`][crate::prelude::ExtractableExt::asset()].
    ///
    /// # Implements
    ///
    /// [`ExtractableExt`][trait@crate::prelude::ExtractableExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "GESExtractable")]
    pub struct Extractable(Interface<ffi::GESExtractable, ffi::GESExtractableInterface>);

    match fn {
        type_ => || ffi::ges_extractable_get_type(),
    }
}

impl Extractable {
    pub const NONE: Option<&'static Extractable> = None;
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Extractable>> Sealed for T {}
}

/// Trait containing all [`struct@Extractable`] methods.
///
/// # Implementors
///
/// [`AudioSource`][struct@crate::AudioSource], [`AudioTestSource`][struct@crate::AudioTestSource], [`AudioTransition`][struct@crate::AudioTransition], [`AudioUriSource`][struct@crate::AudioUriSource], [`BaseEffectClip`][struct@crate::BaseEffectClip], [`BaseEffect`][struct@crate::BaseEffect], [`BaseTransitionClip`][struct@crate::BaseTransitionClip], [`BaseXmlFormatter`][struct@crate::BaseXmlFormatter], [`Clip`][struct@crate::Clip], [`CommandLineFormatter`][struct@crate::CommandLineFormatter], [`Container`][struct@crate::Container], [`EffectClip`][struct@crate::EffectClip], [`Effect`][struct@crate::Effect], [`Extractable`][struct@crate::Extractable], [`Formatter`][struct@crate::Formatter], [`Group`][struct@crate::Group], [`ImageSource`][struct@crate::ImageSource], [`Layer`][struct@crate::Layer], [`MultiFileSource`][struct@crate::MultiFileSource], [`OperationClip`][struct@crate::OperationClip], [`Operation`][struct@crate::Operation], [`OverlayClip`][struct@crate::OverlayClip], [`SourceClip`][struct@crate::SourceClip], [`Source`][struct@crate::Source], [`TestClip`][struct@crate::TestClip], [`TextOverlayClip`][struct@crate::TextOverlayClip], [`TextOverlay`][struct@crate::TextOverlay], [`TimelineElement`][struct@crate::TimelineElement], [`Timeline`][struct@crate::Timeline], [`TitleClip`][struct@crate::TitleClip], [`TitleSource`][struct@crate::TitleSource], [`TrackElement`][struct@crate::TrackElement], [`TransitionClip`][struct@crate::TransitionClip], [`Transition`][struct@crate::Transition], [`UriClip`][struct@crate::UriClip], [`VideoSource`][struct@crate::VideoSource], [`VideoTestSource`][struct@crate::VideoTestSource], [`VideoTransition`][struct@crate::VideoTransition], [`VideoUriSource`][struct@crate::VideoUriSource], [`XmlFormatter`][struct@crate::XmlFormatter]
pub trait ExtractableExt: IsA<Extractable> + sealed::Sealed + 'static {
    /// Get the asset that has been set on the extractable object.
    ///
    /// # Returns
    ///
    /// The asset set on `self`, or [`None`]
    /// if no asset has been set.
    #[doc(alias = "ges_extractable_get_asset")]
    #[doc(alias = "get_asset")]
    fn asset(&self) -> Option<Asset> {
        unsafe {
            from_glib_none(ffi::ges_extractable_get_asset(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the [`id`][struct@crate::Asset#id] of some associated asset. It may be the case
    /// that the object has no set asset, or even that such an asset does not
    /// yet exist in the GES cache. Instead, this will return the asset
    /// [`id`][struct@crate::Asset#id] that is _compatible_ with the current state of the object,
    /// as determined by the [`Extractable`][crate::Extractable] implementer. If it was indeed
    /// extracted from an asset, this should return the same as its
    /// corresponding asset [`id`][struct@crate::Asset#id].
    ///
    /// # Returns
    ///
    /// The [`id`][struct@crate::Asset#id] of some associated [`Asset`][crate::Asset]
    /// that is compatible with `self`'s current state.
    #[doc(alias = "ges_extractable_get_id")]
    #[doc(alias = "get_id")]
    fn id(&self) -> glib::GString {
        unsafe { from_glib_full(ffi::ges_extractable_get_id(self.as_ref().to_glib_none().0)) }
    }

    /// Sets the asset for this extractable object.
    ///
    /// When an object is extracted from an asset using [`AssetExt::extract()`][crate::prelude::AssetExt::extract()] its
    /// asset will be automatically set. Note that many classes that implement
    /// [`Extractable`][crate::Extractable] will automatically create their objects using assets
    /// when you call their `new` methods. However, you can use this method to
    /// associate an object with a compatible asset if it was created by other
    /// means and does not yet have an asset. Or, for some implementations of
    /// [`Extractable`][crate::Extractable], you can use this to change the asset of the given
    /// extractable object, which will lead to a change in its state to
    /// match the new asset [`id`][struct@crate::Asset#id].
    /// ## `asset`
    /// The asset to set
    ///
    /// # Returns
    ///
    /// [`true`] if `asset` could be successfully set on `self`.
    #[doc(alias = "ges_extractable_set_asset")]
    fn set_asset(&self, asset: &impl IsA<Asset>) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_extractable_set_asset(
                    self.as_ref().to_glib_none().0,
                    asset.as_ref().to_glib_none().0
                ),
                "Failed to set asset"
            )
        }
    }
}

impl<O: IsA<Extractable>> ExtractableExt for O {}