diff options
author | Federico Mena Quintero <federico@gnome.org> | 2021-01-21 13:47:46 -0600 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2021-01-21 14:03:59 -0600 |
commit | 10a75a0d22d388d5a151b28de792ab8a9dd67432 (patch) | |
tree | 1aeaaa4ad190681fe6378ae17ccd7b7faff87211 | |
parent | c2541401a867520670c1fa92d60c7be6cf3d0dcf (diff) | |
download | librsvg-10a75a0d22d388d5a151b28de792ab8a9dd67432.tar.gz |
Export PathOrUrl for rsvg-convert and impl some common traits for it
-rw-r--r-- | src/c_api/handle.rs | 12 | ||||
-rw-r--r-- | src/c_api/mod.rs | 2 | ||||
-rw-r--r-- | 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; @@ -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; } |