librsvg_rebind/lib.rs
1#![allow(clippy::needless_doctest_main)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3#![doc(html_logo_url = "https://gnome.pages.gitlab.gnome.org/librsvg/Rsvg-2.0/librsvg-r.svg")]
4//! # Rust librsvg bindings
5//!
6//! This package contains safe Rust bindings for the librsvg C library.
7//!
8//! Since librsvg is written in Rust, the native [`rsvg`] crate is available
9//! to use the same features. One of the main purposes of *librsvg-rebind*
10//! is to reduce the binary sice.
11//!
12//! To use this package, the *librsvg-2* library has to be available on the system.
13//! If you use the native [`rsvg`] crate, this is not required.
14//!
15//! [`rsvg`]: https://crates.io/crates/librsvg
16//!
17//! # Example
18//!
19//! ```
20//! use librsvg_rebind::prelude::*;
21//!
22//! let handle = librsvg_rebind::Handle::from_file("../../rsvg/example.svg")
23//! .unwrap()
24//! .unwrap();
25//!
26//! let (width, height) = handle.intrinsic_size_in_pixels().unwrap();
27//!
28//! let surface =
29//! cairo::ImageSurface::create(cairo::Format::ARgb32, width as i32, height as i32).unwrap();
30//! let context = cairo::Context::new(&surface).unwrap();
31//!
32//! let viewport = librsvg_rebind::Rectangle::new(0., 0., height, width);
33//!
34//! handle.render_document(&context, &viewport).unwrap();
35//!
36//! let mut output_file = std::fs::File::create("/dev/null").unwrap();
37//! surface.write_to_png(&mut output_file).unwrap();
38//! ```
39
40/// No-op.
41macro_rules! skip_assert_initialized {
42 () => {};
43}
44
45// Re-export the -sys bindings
46pub use ffi;
47pub use gio;
48pub use glib;
49
50/// No-op.
51macro_rules! assert_initialized_main_thread {
52 () => {};
53}
54
55mod auto;
56mod handle;
57mod length;
58mod rectangle;
59mod unit;
60
61pub use auto::*;
62pub use length::*;
63pub use rectangle::*;
64pub mod prelude;