libappstream::prelude

Trait PoolExt

source
pub trait PoolExt:
    IsA<Pool>
    + Sealed
    + 'static {
Show 26 methods // Provided methods fn add_components(&self, cbox: &impl IsA<ComponentBox>) -> Result<(), Error> { ... } fn add_extra_data_location( &self, directory: &str, format_style: FormatStyle, ) { ... } fn add_flags(&self, flags: PoolFlags) { ... } fn build_search_tokens(&self, search: &str) -> Vec<GString> { ... } fn clear(&self) { ... } fn components(&self) -> Option<ComponentBox> { ... } fn components_by_bundle_id( &self, kind: BundleKind, bundle_id: &str, match_prefix: bool, ) -> Option<ComponentBox> { ... } fn components_by_categories( &self, categories: &[&str], ) -> Option<ComponentBox> { ... } fn components_by_extends(&self, extended_id: &str) -> Option<ComponentBox> { ... } fn components_by_id(&self, cid: &str) -> Option<ComponentBox> { ... } fn components_by_kind(&self, kind: ComponentKind) -> Option<ComponentBox> { ... } fn components_by_launchable( &self, kind: LaunchableKind, id: &str, ) -> Option<ComponentBox> { ... } fn components_by_provided_item( &self, kind: ProvidedKind, item: &str, ) -> Option<ComponentBox> { ... } fn flags(&self) -> PoolFlags { ... } fn locale(&self) -> Option<GString> { ... } fn is_empty(&self) -> bool { ... } fn load( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error> { ... } fn load_async<P: FnOnce(Result<(), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, ) { ... } fn load_future( &self, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... } fn remove_flags(&self, flags: PoolFlags) { ... } fn reset_extra_data_locations(&self) { ... } fn search(&self, search: &str) -> Option<ComponentBox> { ... } fn set_flags(&self, flags: PoolFlags) { ... } fn set_load_std_data_locations(&self, enabled: bool) { ... } fn set_locale(&self, locale: &str) { ... } fn connect_changed<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Pool methods.

§Implementors

Pool

Provided Methods§

source

fn add_components(&self, cbox: &impl IsA<ComponentBox>) -> Result<(), Error>

Register a set of components with the pool temporarily. Data from components added like this will not be cached.

§cbox

Components to add to the pool.

§Returns

true if the new components were successfully added to the pool.

source

fn add_extra_data_location(&self, directory: &str, format_style: FormatStyle)

Add an additional non-standard location to the metadata pool where metadata will be read from. If directory contains a “xml”, “xmls”, “yaml” or “icons” subdirectory (or all of them), those paths will be added to the search paths instead.

§directory

An existing filesystem location.

§format_style

The expected format style of the metadata, e.g. FormatStyle::Catalog

source

fn add_flags(&self, flags: PoolFlags)

Convenience function to add one or multiple PoolFlags to the flag set of this data pool.

§flags

The PoolFlags to add.

source

fn build_search_tokens(&self, search: &str) -> Vec<GString>

Splits up a string into an array of tokens that are suitable for searching. This includes stripping whitespaces, casefolding the terms and removing greylist words.

This function is usually called automatically when needed, you will only need to run it explicitly when you need to check which search tokens the pool will actually use internally for a given phrase.

§search

the (user-provided) search phrase.

§Returns

(array zero-terminated=1): Valid tokens to search for, or None for error

source

fn clear(&self)

Remove all metadata from the pool, data will be reloaded once as_pool_load is called again.

source

fn components(&self) -> Option<ComponentBox>

Get a list of found components.

§Returns

an ComponentBox.

source

fn components_by_bundle_id( &self, kind: BundleKind, bundle_id: &str, match_prefix: bool, ) -> Option<ComponentBox>

Find components that are provided by a bundle with a specific ID by its prefix. For example, given a AS_BUNDLE_KIND_FLATPAK and a bundle_id “org.kde.dolphin/”, it will list all the components that bundle dolphin. If the bundle_id is “org.kde.dolphin/x86_64” it will give those with also the architecture.

§kind

The kind of the bundle we are looking for

§bundle_id

The bundle ID to match, as specified in Bundle

§match_prefix

true to match the ID by prefix, false to perform an absolute match.

§Returns

an ComponentBox.

source

fn components_by_categories(&self, categories: &[&str]) -> Option<ComponentBox>

Return a list of components which are in all of the categories.

§categories

An array of XDG categories to include.

§Returns

an ComponentBox of found components.

source

fn components_by_extends(&self, extended_id: &str) -> Option<ComponentBox>

Find components extending the component with the given ID. They can then be registered to the Component they extend via as_component_add_addon. If the PoolFlags::RESOLVE_ADDONS pool flag is set, addons are automatically resolved and this explicit function is not needed, but overall query time will be increased (so only use this flag if you will be resolving addon information later anyway).

§extended_id

The ID of the component to search extensions for.

§Returns

an ComponentBox.

source

fn components_by_id(&self, cid: &str) -> Option<ComponentBox>

Get a specific component by its ID. This function may contain multiple results if we have data describing this component from multiple scopes/origin types.

§cid

The AppStream-ID to look for.

§Returns

an ComponentBox.

source

fn components_by_kind(&self, kind: ComponentKind) -> Option<ComponentBox>

Return a list of all components in the pool which are of a certain kind.

§kind

An ComponentKind.

§Returns

an ComponentBox of found components.

source

fn components_by_launchable( &self, kind: LaunchableKind, id: &str, ) -> Option<ComponentBox>

Find components in the AppStream data pool which provide a specific launchable. See Launchable for details on launchables, or refer to the AppStream specification.

§kind

An LaunchableKind

§id

The ID of the launchable.

§Returns

an ComponentBox of found components.

source

fn components_by_provided_item( &self, kind: ProvidedKind, item: &str, ) -> Option<ComponentBox>

Find components in the AppStream data pool which provide a certain item.

§kind

An AsProvidesKind

§item

The value of the provided item.

§Returns

an ComponentBox of found components.

source

fn flags(&self) -> PoolFlags

Get the PoolFlags for this data pool.

source

fn locale(&self) -> Option<GString>

Gets the currently used locale.

§Returns

Locale used for metadata parsing.

source

fn is_empty(&self) -> bool

Check if this pool contains any data.

§Returns

true if the pool is empty.

source

fn load(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<(), Error>

Builds an index of all found components in the watched locations. The function will try to get as much data into the pool as possible, so even if the update completes with false, it might still have added components to the pool.

The function will load from all possible data sources, preferring caches if they are up to date.

§cancellable

a gio::Cancellable.

§Returns

true if update completed without error.

source

fn load_async<P: FnOnce(Result<(), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Asynchronously loads data from all registered locations. Equivalent to load() (but asynchronous)

§cancellable

a gio::Cancellable.

§callback

A GAsyncReadyCallback

source

fn load_future( &self, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

source

fn remove_flags(&self, flags: PoolFlags)

Convenience function to remove one or multiple PoolFlags from the flag set of this data pool.

§flags

The PoolFlags to remove.

source

fn reset_extra_data_locations(&self)

Remove all explicitly added metadata locations.

source

fn search(&self, search: &str) -> Option<ComponentBox>

Search for a list of components matching the search term. The list will be ordered by match score.

§search

A search string

§Returns

an ComponentBox of the found components.

source

fn set_flags(&self, flags: PoolFlags)

Set the PoolFlags for this data pool.

§flags

The new PoolFlags.

source

fn set_load_std_data_locations(&self, enabled: bool)

This is a convenience function that enables or disables loading of metadata from well-known standard locations by configuring the PoolFlags of this Pool accordingly. Data affected by this includes the OS data catalog, metainfo, desktop-entry files and Flatpak data. If you need more fine-grained control, set the PoolFlags explicitly.

§enabled

Whether loading of data from standard locations should be enabled.

source

fn set_locale(&self, locale: &str)

Sets the current locale which should be used when parsing metadata.

§locale

the BCP47 or POSIX locale to use for this pool.

source

fn connect_changed<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId

The ::changed signal is emitted when components have been added or removed from the metadata pool.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<O: IsA<Pool>> PoolExt for O