[librsvg/wip/rust-api: 1/11] librsvg_crate: New crate; this will be the public Rust API for Rust programs



commit cd848439e01378461647dd848918262bf6639193
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Feb 13 09:04:10 2019 -0600

    librsvg_crate: New crate; this will be the public Rust API for Rust programs
    
    The idea is to have this:
    
      rsvg_internals - actual implementation of the library
    
      librsvg - C library, also used for GObject Introspection
    
      librsvg_crate - public crate "librsvg" for Rust callers, visible from crates.io
    
    The crate is not called "rsvg" publically, because the rsvg-rs
    bindings already use that name: https://github.com/selaux/rsvg-rs

 Cargo.lock               | 10 ++++++++++
 Cargo.toml               |  1 +
 Makefile.am              |  5 +++++
 librsvg_crate/Cargo.toml | 14 ++++++++++++++
 librsvg_crate/src/lib.rs | 42 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 72 insertions(+)
---
diff --git a/Cargo.lock b/Cargo.lock
index a76d8b47..641f61d9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -584,6 +584,16 @@ name = "libm"
 version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 
+[[package]]
+name = "librsvg"
+version = "0.0.1"
+dependencies = [
+ "cairo-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rsvg_internals 0.0.1",
+ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "locale_config"
 version = "0.2.2"
diff --git a/Cargo.toml b/Cargo.toml
index 5b5dfcd5..9bde4269 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,6 @@
 [workspace]
 members = [
+    "librsvg_crate",
     "rsvg_internals",
 ]
 
diff --git a/Makefile.am b/Makefile.am
index f839bbaa..fed1e52b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -114,6 +114,10 @@ RUST_SRC =                                                 \
        rsvg_internals/src/xml2.rs                              \
        rsvg_internals/src/xml2_load.rs
 
+LIBRSVG_CRATE_SOURCES =                                        \
+       librsvg_crate/Cargo.toml                                \
+       librsvg_crate/src/lib.rs
+
 RUST_EXTRA =                                           \
        Cargo.lock                                      \
        cargo-vendor-config                             \
@@ -263,6 +267,7 @@ dist_doc_DATA =                             \
 EXTRA_DIST =                           \
        $(RUST_SRC)                     \
        $(RUST_EXTRA)                   \
+       $(LIBRSVG_CRATE_SOURCES)        \
        librsvg.doap                    \
        AUTHORS                         \
        NEWS                            \
diff --git a/librsvg_crate/Cargo.toml b/librsvg_crate/Cargo.toml
new file mode 100644
index 00000000..0fda9988
--- /dev/null
+++ b/librsvg_crate/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "librsvg"
+version = "0.0.1"
+authors = ["Federico Mena Quintero <federico gnome org>"]
+workspace = "../"
+
+[lib]
+name = "librsvg"
+
+[dependencies]
+cairo-rs = "0.5.0"
+gio = { version="0.5.1", features=["v2_48"] } # per configure.ac
+rsvg_internals = { path = "../rsvg_internals" }
+url = "1.7.2"
diff --git a/librsvg_crate/src/lib.rs b/librsvg_crate/src/lib.rs
new file mode 100644
index 00000000..abb21df7
--- /dev/null
+++ b/librsvg_crate/src/lib.rs
@@ -0,0 +1,42 @@
+#![warn(unused)]
+extern crate rsvg_internals;
+extern crate url;
+
+use url::Url;
+
+/// Full configuration for loading an [`SvgHandle`][SvgHandle]
+///
+/// [SvgHandle]: struct.SvgHandle.html
+pub struct LoadOptions {
+    unlimited_size: bool,
+    keep_image_data: bool,
+    base_url: Option<Url>,
+}
+
+impl LoadOptions {
+    pub fn new() -> Self {
+        LoadOptions {
+            unlimited_size: false,
+            keep_image_data: false,
+            base_url: None,
+        }
+    }
+
+    pub fn base_url(mut self, url: Option<&Url>) -> Self {
+        self.base_url = url.map(|u| u.clone());
+        self
+    }
+
+    pub fn unlimited_size(mut self, unlimited: bool) -> Self {
+        self.unlimited_size = unlimited;
+        self
+    }
+
+    pub fn keep_image_data(mut self, keep: bool) -> Self {
+        self.keep_image_data = keep;
+        self
+    }
+}
+
+pub struct SvgHandle {
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]