Skip to content

Commit 8e0d925

Browse files
authored
Merge pull request #905 from sdroege/pixbuf-nullability
gdk-pixbuf: Trust return value nullability
2 parents 459c298 + 4fe2e3a commit 8e0d925

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

gdk-pixbuf/Gir.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ work_mode = "normal"
88
use_gi_docgen = true
99
single_version_file = true
1010
deprecate_by_min_version = true
11+
trust_return_value_nullability = true
1112

1213
generate = [
1314
"GdkPixbuf.Colorspace",
@@ -148,6 +149,10 @@ manual_traits = ["PixbufAnimationExtManual"]
148149
[object.function.return]
149150
# see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108
150151
nullable = false
152+
[[object.function]]
153+
name = "get_static_image"
154+
[object.function.return]
155+
nullable = true
151156

152157
[[object]]
153158
name = "GdkPixbuf.PixbufFormat"

gdk-pixbuf/src/auto/pixbuf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl Pixbuf {
222222

223223
#[doc(alias = "gdk_pixbuf_add_alpha")]
224224
#[must_use]
225-
pub fn add_alpha(&self, substitute_color: bool, r: u8, g: u8, b: u8) -> Option<Pixbuf> {
225+
pub fn add_alpha(&self, substitute_color: bool, r: u8, g: u8, b: u8) -> Pixbuf {
226226
unsafe {
227227
from_glib_full(ffi::gdk_pixbuf_add_alpha(
228228
self.to_glib_none().0,
@@ -472,7 +472,7 @@ impl Pixbuf {
472472

473473
#[doc(alias = "gdk_pixbuf_new_subpixbuf")]
474474
#[must_use]
475-
pub fn new_subpixbuf(&self, src_x: i32, src_y: i32, width: i32, height: i32) -> Option<Pixbuf> {
475+
pub fn new_subpixbuf(&self, src_x: i32, src_y: i32, width: i32, height: i32) -> Pixbuf {
476476
unsafe {
477477
from_glib_full(ffi::gdk_pixbuf_new_subpixbuf(
478478
self.to_glib_none().0,
@@ -485,7 +485,7 @@ impl Pixbuf {
485485
}
486486

487487
#[doc(alias = "gdk_pixbuf_read_pixel_bytes")]
488-
pub fn read_pixel_bytes(&self) -> Option<glib::Bytes> {
488+
pub fn read_pixel_bytes(&self) -> glib::Bytes {
489489
unsafe { from_glib_full(ffi::gdk_pixbuf_read_pixel_bytes(self.to_glib_none().0)) }
490490
}
491491

gdk-pixbuf/src/auto/pixbuf_format.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// DO NOT EDIT
44

55
use glib::translate::*;
6+
use std::fmt;
67

78
glib::wrapper! {
89
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -18,7 +19,7 @@ glib::wrapper! {
1819
impl PixbufFormat {
1920
#[doc(alias = "gdk_pixbuf_format_get_description")]
2021
#[doc(alias = "get_description")]
21-
pub fn description(&self) -> Option<glib::GString> {
22+
pub fn description(&self) -> glib::GString {
2223
unsafe {
2324
from_glib_full(ffi::gdk_pixbuf_format_get_description(mut_override(
2425
self.to_glib_none().0,
@@ -38,7 +39,7 @@ impl PixbufFormat {
3839

3940
#[doc(alias = "gdk_pixbuf_format_get_license")]
4041
#[doc(alias = "get_license")]
41-
pub fn license(&self) -> Option<glib::GString> {
42+
pub fn license(&self) -> glib::GString {
4243
unsafe {
4344
from_glib_full(ffi::gdk_pixbuf_format_get_license(mut_override(
4445
self.to_glib_none().0,
@@ -58,7 +59,7 @@ impl PixbufFormat {
5859

5960
#[doc(alias = "gdk_pixbuf_format_get_name")]
6061
#[doc(alias = "get_name")]
61-
pub fn name(&self) -> Option<glib::GString> {
62+
pub fn name(&self) -> glib::GString {
6263
unsafe {
6364
from_glib_full(ffi::gdk_pixbuf_format_get_name(mut_override(
6465
self.to_glib_none().0,
@@ -111,5 +112,12 @@ impl PixbufFormat {
111112
}
112113
}
113114

115+
impl fmt::Display for PixbufFormat {
116+
#[inline]
117+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
118+
f.write_str(&self.name())
119+
}
120+
}
121+
114122
unsafe impl Send for PixbufFormat {}
115123
unsafe impl Sync for PixbufFormat {}

0 commit comments

Comments
 (0)