[librsvg: 5/11] Implement some common traits for PathOrUrl
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 5/11] Implement some common traits for PathOrUrl
- Date: Wed, 3 Feb 2021 00:47:26 +0000 (UTC)
commit 4ef4139e933f7cd89ea67d5f816c2e2c1bc5ff3a
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Jan 21 13:47:46 2021 -0600
Implement some common traits for PathOrUrl
src/c_api/handle.rs | 12 +++++++++++-
src/c_api/mod.rs | 2 +-
2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/c_api/handle.rs b/src/c_api/handle.rs
index 674f6030..4fe21747 100644
--- a/src/c_api/handle.rs
+++ b/src/c_api/handle.rs
@@ -2143,7 +2143,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),
}
@@ -2185,6 +2186,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 b7003df8..a143c3d0 100644
--- a/src/c_api/mod.rs
+++ b/src/c_api/mod.rs
@@ -51,6 +51,6 @@ mod messages;
mod color_utils;
mod dpi;
-mod handle;
+pub mod handle;
pub mod pixbuf_utils;
mod sizing;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]