[librsvg: 4/6] handle::acquire_stream(): Bind to Rust
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/6] handle::acquire_stream(): Bind to Rust
- Date: Sat, 24 Nov 2018 01:07:19 +0000 (UTC)
commit ba387c61064c82a6268015385cc0776b4f6dc835
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Nov 23 18:12:00 2018 -0600
handle::acquire_stream(): Bind to Rust
rsvg_internals/src/handle.rs | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index c6b91429..267c010d 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -3,6 +3,8 @@ use std::ptr;
use cairo::{ImageSurface, Status};
use cairo_sys;
use gdk_pixbuf::{PixbufLoader, PixbufLoaderExt};
+use gio::InputStream;
+use gio_sys;
use glib;
use glib::translate::*;
use glib_sys;
@@ -40,6 +42,12 @@ extern "C" {
error: *mut *mut glib_sys::GError,
) -> *mut u8;
+ fn _rsvg_handle_acquire_stream(
+ handle: *mut RsvgHandle,
+ href: *const libc::c_char,
+ error: *mut *mut glib_sys::GError,
+ ) -> *mut gio_sys::GInputStream;
+
fn rsvg_handle_keep_image_data(handle: *const RsvgHandle) -> glib_sys::gboolean;
fn rsvg_load_handle_xml_xinclude(
@@ -115,6 +123,24 @@ pub fn acquire_data(handle: *mut RsvgHandle, href: &str) -> Result<BinaryData, g
}
}
+pub fn acquire_stream(handle: *mut RsvgHandle, href: &str) -> Result<InputStream, glib::Error> {
+ unsafe {
+ let mut error = ptr::null_mut();
+
+ let stream = _rsvg_handle_acquire_stream(
+ handle,
+ href.to_glib_none().0,
+ &mut error,
+ );
+
+ if stream.is_null() {
+ Err(from_glib_full(error))
+ } else {
+ Ok(from_glib_full(stream))
+ }
+ }
+}
+
fn keep_image_data(handle: *const RsvgHandle) -> bool {
unsafe { from_glib(rsvg_handle_keep_image_data(handle)) }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]