[librsvg] drawing_ctx::state_get_stop_color(): Return a Result<Color>, not a ColorSpec



commit 0112a1e8a1cc50ebd601c22d8e08003f01aefe61
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed May 31 13:02:40 2017 -0500

    drawing_ctx::state_get_stop_color(): Return a Result<Color>, not a ColorSpec
    
    We want to use ColorSpec only for marshalling to/from C.  Inside the
    Rust code we only want to use a Color enum, and indicate a parse error
    thereof by a Result<Color, ...>.

 rust/src/drawing_ctx.rs |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/rust/src/drawing_ctx.rs b/rust/src/drawing_ctx.rs
index f07d436..b3754df 100644
--- a/rust/src/drawing_ctx.rs
+++ b/rust/src/drawing_ctx.rs
@@ -7,6 +7,8 @@ extern crate libc;
 use self::glib::translate::*;
 
 use color::*;
+use error::*;
+use opacity::*;
 use node::RsvgNode;
 use node::NodeType;
 use path_builder::RsvgPathBuilder;
@@ -236,14 +238,14 @@ pub fn state_pop (draw_ctx: *const RsvgDrawingCtx) {
     }
 }
 
-pub fn state_get_stop_color (state: *const RsvgState) -> Option<ColorSpec> {
+pub fn state_get_stop_color (state: *const RsvgState) -> Result<Option<Color>, AttributeError> {
     unsafe {
         let spec_ptr = rsvg_state_get_stop_color (state);
 
         if spec_ptr.is_null () {
-            None
+            Ok (None)
         } else {
-            Some (*spec_ptr)
+            Color::from_color_spec (&*spec_ptr).map (|color| Some (color))
         }
     }
 }


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