libappstream/auto/release.rs
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::{ffi, Artifact, Context, Issue, ReleaseKind, ReleaseUrlKind, UrgencyKind};
use glib::{prelude::*, translate::*};
glib::wrapper! {
///
///
/// # Implements
///
/// [`ReleaseExt`][trait@crate::prelude::ReleaseExt]
#[doc(alias = "AsRelease")]
pub struct Release(Object<ffi::AsRelease, ffi::AsReleaseClass>);
match fn {
type_ => || ffi::as_release_get_type(),
}
}
impl Release {
pub const NONE: Option<&'static Release> = None;
/// Creates a new [`Release`][crate::Release].
///
/// # Returns
///
/// a [`Release`][crate::Release]
#[doc(alias = "as_release_new")]
pub fn new() -> Release {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::as_release_new()) }
}
}
impl Default for Release {
fn default() -> Self {
Self::new()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Release>> Sealed for T {}
}
/// Trait containing all [`struct@Release`] methods.
///
/// # Implementors
///
/// [`Release`][struct@crate::Release]
pub trait ReleaseExt: IsA<Release> + sealed::Sealed + 'static {
/// Add an artifact (binary / source download) for this release.
/// ## `artifact`
/// The [`Artifact`][crate::Artifact].
#[doc(alias = "as_release_add_artifact")]
fn add_artifact(&self, artifact: &impl IsA<Artifact>) {
unsafe {
ffi::as_release_add_artifact(
self.as_ref().to_glib_none().0,
artifact.as_ref().to_glib_none().0,
);
}
}
/// Add information about a (resolved) issue to this release.
/// ## `issue`
/// The [`Issue`][crate::Issue].
#[doc(alias = "as_release_add_issue")]
fn add_issue(&self, issue: &impl IsA<Issue>) {
unsafe {
ffi::as_release_add_issue(
self.as_ref().to_glib_none().0,
issue.as_ref().to_glib_none().0,
);
}
}
/// Add a tag to this release.
/// ## `ns`
/// The namespace the tag belongs to
/// ## `tag`
/// The tag name
///
/// # Returns
///
/// [`true`] if the tag was added.
#[doc(alias = "as_release_add_tag")]
fn add_tag(&self, ns: &str, tag: &str) -> bool {
unsafe {
from_glib(ffi::as_release_add_tag(
self.as_ref().to_glib_none().0,
ns.to_glib_none().0,
tag.to_glib_none().0,
))
}
}
/// Remove all tags associated with this release.
#[doc(alias = "as_release_clear_tags")]
fn clear_tags(&self) {
unsafe {
ffi::as_release_clear_tags(self.as_ref().to_glib_none().0);
}
}
/// Get a list of all downloadable artifacts that are associated with
/// this release.
///
/// # Returns
///
/// an array of [`Artifact`][crate::Artifact] objects.
#[doc(alias = "as_release_get_artifacts")]
#[doc(alias = "get_artifacts")]
fn artifacts(&self) -> Vec<Artifact> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::as_release_get_artifacts(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// the [`Context`][crate::Context] associated with this release.
/// This function may return [`None`] if no context is set.
#[doc(alias = "as_release_get_context")]
#[doc(alias = "get_context")]
fn context(&self) -> Option<Context> {
unsafe { from_glib_none(ffi::as_release_get_context(self.as_ref().to_glib_none().0)) }
}
/// Gets the release date.
///
/// # Returns
///
/// The date in ISO8601 format.
#[doc(alias = "as_release_get_date")]
#[doc(alias = "get_date")]
fn date(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::as_release_get_date(self.as_ref().to_glib_none().0)) }
}
/// Gets the end-of-life date for this release.
///
/// # Returns
///
/// The EOL date in ISO8601 format.
#[doc(alias = "as_release_get_date_eol")]
#[doc(alias = "get_date_eol")]
fn date_eol(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::as_release_get_date_eol(self.as_ref().to_glib_none().0)) }
}
/// Gets the release description markup for a given locale.
///
/// # Returns
///
/// markup, or [`None`] for not set or invalid
#[doc(alias = "as_release_get_description")]
#[doc(alias = "get_description")]
fn description(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::as_release_get_description(
self.as_ref().to_glib_none().0,
))
}
}
/// Get a list of all issues resolved by this release.
///
/// # Returns
///
/// an array of [`Issue`][crate::Issue] objects.
#[doc(alias = "as_release_get_issues")]
#[doc(alias = "get_issues")]
fn issues(&self) -> Vec<Issue> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::as_release_get_issues(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the type of the release.
/// (development or stable release)
#[doc(alias = "as_release_get_kind")]
#[doc(alias = "get_kind")]
fn kind(&self) -> ReleaseKind {
unsafe { from_glib(ffi::as_release_get_kind(self.as_ref().to_glib_none().0)) }
}
/// Gets the release timestamp.
///
/// # Returns
///
/// timestamp, or 0 for unset
#[doc(alias = "as_release_get_timestamp")]
#[doc(alias = "get_timestamp")]
fn timestamp(&self) -> u64 {
unsafe { ffi::as_release_get_timestamp(self.as_ref().to_glib_none().0) }
}
/// Gets the UNIX timestamp for the date when this
/// release is out of support (end-of-life).
///
/// # Returns
///
/// UNIX timestamp, or 0 for unset or invalid.
#[doc(alias = "as_release_get_timestamp_eol")]
#[doc(alias = "get_timestamp_eol")]
fn timestamp_eol(&self) -> u64 {
unsafe { ffi::as_release_get_timestamp_eol(self.as_ref().to_glib_none().0) }
}
/// Gets the urgency of the release
/// (showing how important it is to update to a more recent release)
///
/// # Returns
///
/// [`UrgencyKind`][crate::UrgencyKind], or [`UrgencyKind::Unknown`][crate::UrgencyKind::Unknown] for not set
#[doc(alias = "as_release_get_urgency")]
#[doc(alias = "get_urgency")]
fn urgency(&self) -> UrgencyKind {
unsafe { from_glib(ffi::as_release_get_urgency(self.as_ref().to_glib_none().0)) }
}
/// Gets an URL.
/// ## `url_kind`
/// the URL kind, e.g. [`ReleaseUrlKind::Details`][crate::ReleaseUrlKind::Details].
///
/// # Returns
///
/// string, or [`None`] if unset
#[doc(alias = "as_release_get_url")]
#[doc(alias = "get_url")]
fn url(&self, url_kind: ReleaseUrlKind) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::as_release_get_url(
self.as_ref().to_glib_none().0,
url_kind.into_glib(),
))
}
}
/// Gets the release version.
///
/// # Returns
///
/// string, or [`None`] for not set or invalid
#[doc(alias = "as_release_get_version")]
#[doc(alias = "get_version")]
fn version(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::as_release_get_version(self.as_ref().to_glib_none().0)) }
}
/// Test if the release is tagged with the selected tag.
/// ## `ns`
/// The namespace the tag belongs to
/// ## `tag`
/// The tag name
///
/// # Returns
///
/// [`true`] if tag exists.
#[doc(alias = "as_release_has_tag")]
fn has_tag(&self, ns: &str, tag: &str) -> bool {
unsafe {
from_glib(ffi::as_release_has_tag(
self.as_ref().to_glib_none().0,
ns.to_glib_none().0,
tag.to_glib_none().0,
))
}
}
/// Remove a tag from this release
/// ## `ns`
/// The namespace the tag belongs to
/// ## `tag`
/// The tag name
///
/// # Returns
///
/// [`true`] if the tag was removed.
#[doc(alias = "as_release_remove_tag")]
fn remove_tag(&self, ns: &str, tag: &str) -> bool {
unsafe {
from_glib(ffi::as_release_remove_tag(
self.as_ref().to_glib_none().0,
ns.to_glib_none().0,
tag.to_glib_none().0,
))
}
}
/// Sets the document context this release is associated
/// with.
/// ## `context`
/// the [`Context`][crate::Context].
#[doc(alias = "as_release_set_context")]
fn set_context(&self, context: &impl IsA<Context>) {
unsafe {
ffi::as_release_set_context(
self.as_ref().to_glib_none().0,
context.as_ref().to_glib_none().0,
);
}
}
/// Sets the release date.
/// ## `date`
/// the date in ISO8601 format.
#[doc(alias = "as_release_set_date")]
fn set_date(&self, date: &str) {
unsafe {
ffi::as_release_set_date(self.as_ref().to_glib_none().0, date.to_glib_none().0);
}
}
/// Sets the end-of-life date for this release.
/// ## `date`
/// the EOL date in ISO8601 format.
#[doc(alias = "as_release_set_date_eol")]
fn set_date_eol(&self, date: &str) {
unsafe {
ffi::as_release_set_date_eol(self.as_ref().to_glib_none().0, date.to_glib_none().0);
}
}
/// Sets the description release markup.
/// ## `description`
/// the description markup.
/// ## `locale`
/// the BCP47 locale, or [`None`]. e.g. "en-GB".
#[doc(alias = "as_release_set_description")]
fn set_description(&self, description: &str, locale: Option<&str>) {
unsafe {
ffi::as_release_set_description(
self.as_ref().to_glib_none().0,
description.to_glib_none().0,
locale.to_glib_none().0,
);
}
}
/// Sets the release kind to distinguish between end-user ready
/// stable releases and development prereleases..
/// ## `kind`
/// the [`ReleaseKind`][crate::ReleaseKind]
#[doc(alias = "as_release_set_kind")]
fn set_kind(&self, kind: ReleaseKind) {
unsafe {
ffi::as_release_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
}
}
/// Sets the release timestamp.
/// ## `timestamp`
/// the timestamp value.
#[doc(alias = "as_release_set_timestamp")]
fn set_timestamp(&self, timestamp: u64) {
unsafe {
ffi::as_release_set_timestamp(self.as_ref().to_glib_none().0, timestamp);
}
}
/// Sets the UNIX timestamp for the date when this
/// release is out of support (end-of-life).
/// ## `timestamp`
/// the timestamp value.
#[doc(alias = "as_release_set_timestamp_eol")]
fn set_timestamp_eol(&self, timestamp: u64) {
unsafe {
ffi::as_release_set_timestamp_eol(self.as_ref().to_glib_none().0, timestamp);
}
}
/// Sets the release urgency.
/// ## `urgency`
/// the urgency of this release/update (as [`UrgencyKind`][crate::UrgencyKind])
#[doc(alias = "as_release_set_urgency")]
fn set_urgency(&self, urgency: UrgencyKind) {
unsafe {
ffi::as_release_set_urgency(self.as_ref().to_glib_none().0, urgency.into_glib());
}
}
/// Sets an URL for this release.
/// ## `url_kind`
/// the URL kind, e.g. [`ReleaseUrlKind::Details`][crate::ReleaseUrlKind::Details]
/// ## `url`
/// the full URL.
#[doc(alias = "as_release_set_url")]
fn set_url(&self, url_kind: ReleaseUrlKind, url: &str) {
unsafe {
ffi::as_release_set_url(
self.as_ref().to_glib_none().0,
url_kind.into_glib(),
url.to_glib_none().0,
);
}
}
/// Sets the release version.
/// ## `version`
/// the version string.
#[doc(alias = "as_release_set_version")]
fn set_version(&self, version: &str) {
unsafe {
ffi::as_release_set_version(self.as_ref().to_glib_none().0, version.to_glib_none().0);
}
}
/// Compare the version numbers of two releases.
/// ## `rel2`
/// an [`Release`][crate::Release]
///
/// # Returns
///
/// 1 if `self` version is higher than `rel2`, 0 if versions are equal, -1 if `rel2` version is higher than `self`.
#[doc(alias = "as_release_vercmp")]
fn vercmp(&self, rel2: &impl IsA<Release>) -> i32 {
unsafe {
ffi::as_release_vercmp(
self.as_ref().to_glib_none().0,
rel2.as_ref().to_glib_none().0,
)
}
}
}
impl<O: IsA<Release>> ReleaseExt for O {}