[librsvg/rustify-rsvg-convert] Export PathOrUrl for rsvg-convert and impl some common traits for it
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustify-rsvg-convert] Export PathOrUrl for rsvg-convert and impl some common traits for it
- Date: Thu, 21 Jan 2021 20:06:56 +0000 (UTC)
commit 10a75a0d22d388d5a151b28de792ab8a9dd67432
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Jan 21 13:47:46 2021 -0600
Export PathOrUrl for rsvg-convert and impl some common traits for it
src/c_api/handle.rs | 12 +++++++++++-
src/c_api/mod.rs | 2 +-
src/lib.rs | 1 +
3 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/c_api/handle.rs b/src/c_api/handle.rs
index 5e6208f5..01b2ebb6 100644
--- a/src/c_api/handle.rs
+++ b/src/c_api/handle.rs
@@ -2131,7 +2131,8 @@ pub unsafe extern "C" fn rsvg_cleanup() {}
/// `gio::File::new_for_path()` or `gio::File::new_for_uri()` as appropriate.
///
/// This enum does the magic heuristics to figure this out.
-enum PathOrUrl {
+#[derive(Clone, Debug)]
+pub enum PathOrUrl {
Path(PathBuf),
Url(Url),
}
@@ -2173,6 +2174,15 @@ impl PathOrUrl {
}
}
+impl fmt::Display for PathOrUrl {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match *self {
+ PathOrUrl::Path(ref p) => p.display().fmt(f),
+ PathOrUrl::Url(ref u) => u.fmt(f),
+ }
+ }
+}
+
fn check_cairo_context(cr: &cairo::Context) -> Result<(), RenderingError> {
let status = cr.status();
if status == cairo::Status::Success {
diff --git a/src/c_api/mod.rs b/src/c_api/mod.rs
index fc14ab0d..fae73f75 100644
--- a/src/c_api/mod.rs
+++ b/src/c_api/mod.rs
@@ -48,6 +48,6 @@ pub use pixbuf_utils::{
mod messages;
mod dpi;
-mod handle;
+pub mod handle;
pub mod pixbuf_utils;
pub mod sizing;
diff --git a/src/lib.rs b/src/lib.rs
index 0e2595b5..53dc5c63 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -158,5 +158,6 @@ pub mod doctest_only {
#[doc(hidden)]
pub mod rsvg_convert_only {
+ pub use crate::c_api::handle::PathOrUrl;
pub use crate::c_api::sizing::LegacySize;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]