libappstream::prelude

Trait ValidatorExt

source
pub trait ValidatorExt:
    IsA<Validator>
    + Sealed
    + 'static {
Show 19 methods // Provided methods fn add_override( &self, tag: &str, severity_override: IssueSeverity, ) -> Result<(), Error> { ... } fn add_release_bytes( &self, release_fname: &str, release_metadata: &Bytes, ) -> Result<(), Error> { ... } fn add_release_file( &self, release_file: &impl IsA<File>, ) -> Result<(), Error> { ... } fn check_success(&self) -> bool { ... } fn clear_release_data(&self) { ... } fn allows_net(&self) -> bool { ... } fn issue_files_count(&self) -> u32 { ... } fn issues(&self) -> Vec<ValidatorIssue> { ... } fn report_yaml(&self) -> Result<GString, Error> { ... } fn is_strict(&self) -> bool { ... } fn tag_explanation(&self, tag: &str) -> Option<GString> { ... } fn tag_severity(&self, tag: &str) -> IssueSeverity { ... } fn tags(&self) -> Vec<GString> { ... } fn set_allow_net(&self, value: bool) { ... } fn set_strict(&self, is_strict: bool) { ... } fn validate_bytes(&self, metadata: &Bytes) -> bool { ... } fn validate_data(&self, metadata: &str) -> bool { ... } fn validate_file(&self, metadata_file: &impl IsA<File>) -> bool { ... } fn validate_tree(&self, root_dir: &str) -> bool { ... }
}
Expand description

Trait containing all Validator methods.

§Implementors

Validator

Provided Methods§

source

fn add_override( &self, tag: &str, severity_override: IssueSeverity, ) -> Result<(), Error>

Override the severity of a selected tag. For most tags, the severity can not be lowered to a value that makes a validation that would otherwise fail pass (so e.g. an ERROR can not become an INFO). Some tags are explicitly allowed to have their severity lowered to enable validation of e.g. incomplete metadata during development. Increasing the severity of any tag is always allowed.

§tag

the issue tag to override, e.g. “release-time-missing”

§severity_override

the new severity for the tag.

source

fn add_release_bytes( &self, release_fname: &str, release_metadata: &Bytes, ) -> Result<(), Error>

Add release metadata explicitly from bytes.

§release_fname

File basename of the release metadata file to add.

§release_metadata

Data of the release metadata file.

source

fn add_release_file(&self, release_file: &impl IsA<File>) -> Result<(), Error>

Add a release metadata file to the validation process.

§release_file

Release metadata file to add.

source

fn check_success(&self) -> bool

Check the current registered values again and return true if no issues were found that would make the previously validated files fail validation.

Usually you do not need to call this function explicitly, as the as_validator_validate_* functions will already return whether data was valid as return value.

§Returns

true if previously validated files were valid.

source

fn clear_release_data(&self)

Clear all release information that was explicitly added to the validation process.

source

fn allows_net(&self) -> bool

§Returns

true in case we allow network access.

source

fn issue_files_count(&self) -> u32

Get the number of files for which issues have been found.

§Returns

The number of files that have issues.

source

fn issues(&self) -> Vec<ValidatorIssue>

Get a list of found metadata format issues.

§Returns

a list of ValidatorIssue instances, free with g_list_free()

source

fn report_yaml(&self) -> Result<GString, Error>

source

fn is_strict(&self) -> bool

§Returns

true in case we are in strict mode and consider any issues as fatal.

source

fn tag_explanation(&self, tag: &str) -> Option<GString>

Get the explanatory text for a given issue tag.

§Returns

Explanation text.

source

fn tag_severity(&self, tag: &str) -> IssueSeverity

Get the severity for a given issue tag.

§Returns

The IssueSeverity

source

fn tags(&self) -> Vec<GString>

Get an array of all tags known to the validator.

§Returns

A string array of tags

source

fn set_allow_net(&self, value: bool)

If set to true, the validator will be allowed to connect to the internet to e.g. check URLs for validity.

§value

true if remote URLs should be checked for availability.

source

fn set_strict(&self, is_strict: bool)

Enable or disable strict mode. In strict mode, any found issue will result in a failed validation (except for issues of “pedantic” severity). Otherwise, only a “warning” or “error” will cause the validation to fail.

§is_strict

true to enable strict mode.

source

fn validate_bytes(&self, metadata: &Bytes) -> bool

Validate AppStream XML data from a byte array. Remember to run as_validator_clear_issues if you do not want previous validation runs to affect the outcome of this validation.

§metadata

XML metadata as glib::Bytes.

§Returns

true if bytes validated successfully.

source

fn validate_data(&self, metadata: &str) -> bool

Validate AppStream XML data.

§metadata

XML metadata.

§Returns

true if data validated successfully.

source

fn validate_file(&self, metadata_file: &impl IsA<File>) -> bool

Validate an AppStream XML file.

§metadata_file

An AppStream XML file.

§Returns

true if file validated successfully.

source

fn validate_tree(&self, root_dir: &str) -> bool

Validate a full directory tree for issues in AppStream metadata.

§root_dir

The root directory of the filesystem tree that should be validated.

§Returns

true if file validated successfully.

Object Safety§

This trait is not object safe.

Implementors§