glycin/lib.rs
1//! Glycin allows to decode images into [`gdk::Texture`]s and to extract image
2//! metadata. The decoding happens in sandboxed modular image loaders that have
3//! to be provided as binaries. The [`glycin-utils`](glycin_utils) for more
4//! details.
5//!
6//! # Example
7//!
8//! You need to enable the `gdk4` feature for this example to work.
9//!
10//! ```no_run
11//! # use glycin::*;
12//! # async {
13//! let file = gio::File::for_path("image.jpg");
14//! let image = Loader::new(file).load().await?;
15//!
16//! let height = image.details().height();
17//! let texture = image.next_frame().await?.texture();
18//! # Ok::<(), ErrorCtx>(()) };
19//! ```
20//!
21//! You can pass the [`texture`](Frame#structfield.texture) of a [`Frame`] to
22//! [`gtk4::Image::from_paintable()`] to display the image.
23//!
24//! # External Dependencies
25//!
26//! Glycin requires the libraries *libglib2.0*, *liblcms2*, *libfontconfig*, and
27//! *libseccomp* packages to be installed. For the `gdk4` feature, *libgtk-4* is
28//! required as well. To actually work with images, loaders for the respective
29//! formats have to be installed. Glycin provides [loaders] for many formats
30//! that are packaged with many distributions. When working in the default
31//! sandbox mode, the `bwrap` binary of *bubblewrap* is required as well. The
32//! required dependencies can usually be installed through commands like
33//!
34//! ```sh
35//! $ apt install libgtk-4-dev liblcms2-dev libfontconfig-dev libseccomp-dev glycin-loaders bubblewrap
36//! ```
37//!
38//! on Debian/Ubuntu or
39//!
40//! ```sh
41//! $ dnf install gtk4-devel lcms2-devel fontconfig-devel libseccomp-devel glycin-loaders bubblewrap
42//! ```
43//!
44//! on Fedora.
45//!
46//! # Features
47//!
48//! - `gdk4` --- Enables interoperability with [`gdk4`](gdk) by enabling to get
49//! a [`gdk::Texture`] directly.
50//! - `tokio` --- Makes glycin compatible with [`zbus`] using [`tokio`].
51//!
52//! [`gtk4::Image::from_paintable()`]: https://gtk-rs.org/gtk4-rs/git/docs/gtk4/struct.Image.html#method.from_paintable
53//! [loaders]: https://gitlab.gnome.org/GNOME/glycin#supported-image-formats
54
55#[cfg(all(not(feature = "async-io"), not(feature = "tokio")))]
56mod error_message {
57 compile_error!(
58 "\"async-io\" (default) or \"tokio\" must be enabled to provide an async runtime."
59 );
60}
61
62mod api_common;
63mod api_creator;
64mod api_editor;
65mod api_loader;
66#[cfg(feature = "unstable-config")]
67pub mod config;
68#[cfg(not(feature = "unstable-config"))]
69mod config;
70mod dbus;
71mod error;
72mod fontconfig;
73mod icc;
74mod orientation;
75mod pool;
76mod sandbox;
77mod util;
78
79#[cfg(feature = "gobject")]
80pub mod gobject;
81
82pub use api_common::*;
83pub use api_creator::*;
84pub use api_editor::*;
85pub use api_loader::*;
86pub use config::COMPAT_VERSION;
87pub use error::{Error, ErrorContext, ErrorCtx};
88pub use glycin_common::{
89 BinaryData, MemoryFormat, MemoryFormatSelection, Operation, OperationId, Operations,
90};
91pub use gufo_common::cicp::Cicp;
92pub use pool::{Pool, PoolConfig};
93#[cfg(feature = "gdk4")]
94pub use util::gdk_memory_format;