pub fn decode(&mut self, next_chr: char) -> Result<Option<Draw>, DecoderError> {
        use self::DecoderState::*;

        // Next state depends on the character and the current state
        let mut state = DecoderState::Error;
        mem::swap(&mut self.state, &mut state);

        let (next_state, result) = match state {
            None                            => Self::decode_none(next_chr)?,
            Error                           => Err(DecoderError::IsInErrorState)?,

            New                             => Self::decode_new(next_chr)?,
            LineStyle                       => Self::decode_line_style(next_chr)?,
            Dash                            => Self::decode_dash(next_chr)?,
            Color                           => Self::decode_color(next_chr)?,
            Sprite                          => Self::decode_sprite(next_chr)?,
            Transform                       => Self::decode_transform(next_chr)?,
            State                           => Self::decode_state(next_chr)?,

            Move(param)                     => Self::decode_move(next_chr, param)?,
            Line(param)                     => Self::decode_line(next_chr, param)?,
            BezierCurve(param)              => Self::decode_bezier_curve(next_chr, param)?,

            LineStyleWidth(param)           => Self::decode_line_width(next_chr, param)?,
            LineStyleWidthPixels(param)     => Self::decode_line_width_pixels(next_chr, param)?,
            LineStyleJoin(param)            => Self::decode_line_style_join(next_chr, param)?,
            LineStyleCap(param)             => Self::decode_line_style_cap(next_chr, param)?,
            WindingRule                     => Self::decode_winding_rule(next_chr)?,

            DashLength(param)               => Self::decode_dash_length(next_chr, param)?,
            DashOffset(param)               => Self::decode_dash_offset(next_chr, param)?,

            ClearCanvas(param)              => Self::decode_clear_canvas(next_chr, param)?,

            ColorStroke(param)              => Self::decode_color_stroke(next_chr, param)?,
            ColorFill(param)                => Self::decode_color_fill(next_chr, param)?,
            ColorTexture(id, param)         => Self::decode_color_texture(next_chr, id, param)?,
            ColorGradient(id, param)        => Self::decode_color_gradient(next_chr, id, param)?,
            ColorTransform(param)           => Self::decode_color_transform(next_chr, param)?,

            BlendMode(param)                => Self::decode_blend_mode(next_chr, param)?,

            TransformHeight(param)          => Self::decode_transform_height(next_chr, param)?,
            TransformCenter(param)          => Self::decode_transform_center(next_chr, param)?,
            TransformMultiply(param)        => Self::decode_transform_multiply(next_chr, param)?,

            NewLayerU32(param)              => Self::decode_new_layer_u32(next_chr, param)?,
            NewLayerBlendU32(param)         => Self::decode_new_layer_blend_u32(next_chr, param)?,
            NewLayer(param)                 => Self::decode_new_layer(next_chr, param)?,
            NewLayerBlend(layer, blend)     => Self::decode_new_layer_blend(next_chr, layer, blend)?,
            SwapLayers(layer1, param)       => Self::decode_swap_layers(next_chr, layer1, param)?,

            NewSprite(param)                => Self::decode_new_sprite(next_chr, param)?,
            SpriteDraw(param)               => Self::decode_sprite_draw(next_chr, param)?,
            SpriteTransform                 => Self::decode_sprite_transform(next_chr)?,
            SpriteTransformTranslate(param) => Self::decode_sprite_transform_translate(next_chr, param)?,
            SpriteTransformScale(param)     => Self::decode_sprite_transform_scale(next_chr, param)?,
            SpriteTransformRotate(param)    => Self::decode_sprite_transform_rotate(next_chr, param)?,
            SpriteTransformTransform(param) => Self::decode_sprite_transform_transform(next_chr, param)?,

            FontDrawing                                         => Self::decode_font_drawing(next_chr)?,
            FontDrawText(font_id, string_decode, coords)        => Self::decode_font_draw_text(next_chr, font_id, string_decode, coords)?,
            FontBeginLayout(param)                              => Self::decode_font_begin_layout(next_chr, param)?,

            FontOp(font_id)                                     => Self::decode_font_op(next_chr, font_id)?,
            FontOpSize(font_id, size)                           => Self::decode_font_op_size(next_chr, font_id, size)?,
            FontOpData(font_id)                                 => Self::decode_font_op_data(next_chr, font_id)?,
            FontOpTtf(font_id, bytes)                           => Self::decode_font_data_ttf(next_chr, font_id, bytes)?,
            FontOpLayoutText(font_id, string)                   => Self::decode_font_op_layout(next_chr, font_id, string)?,
            FontOpDrawGlyphs(font_id, glyphs)                   => Self::decode_font_op_glyphs(next_chr, font_id, glyphs)?,

            TextureOp(texture_id)                               => Self::decode_texture_op(next_chr, texture_id)?,
            TextureOpCreate(texture_id, param)                  => Self::decode_texture_create(next_chr, texture_id, param)?,
            TextureOpSetBytes(texture_id, param, bytes)         => Self::decode_texture_set_bytes(next_chr, texture_id, param, bytes)?,
            TextureOpFillTransparency(texture_id, param)        => Self::decode_texture_fill_transparency(next_chr, texture_id, param)?,

            GradientOp(gradient_id)                             => Self::decode_gradient_op(next_chr, gradient_id)?,     
            GradientOpNew(gradient_id, param)                   => Self::decode_gradient_new(next_chr, gradient_id, param)?,
            GradientOpAddStop(gradient_id, param)               => Self::decode_gradient_add_stop(next_chr, gradient_id, param)?,
        };

        self.state = next_state;
        Ok(result)
    }
///
/// Decodes a character, returning the next Draw operation if there is one
///
Decodes a character, returning the next Draw operation if there is one
Decodes a character returning the next Draw operation if there is one
pub fn decode(&mut self, next_chr: char) -> Result<Option<Draw>, DecoderError> {
        use self::DecoderState::*;
        // Next state depends on the character and the current state
        let mut state = DecoderState::Error;
        mem::swap(&mut self.state, &mut state);
        let (next_state, result) = match state {
            None                            => Self::decode_none(next_chr)?,
            Error                           => Err(DecoderError::IsInErrorState)?,
            New                             => Self::decode_new(next_chr)?,
            LineStyle                       => Self::decode_line_style(next_chr)?,
            Dash                            => Self::decode_dash(next_chr)?,
            Color                           => Self::decode_color(next_chr)?,
            Sprite                          => Self::decode_sprite(next_chr)?,
            Transform                       => Self::decode_transform(next_chr)?,
            State                           => Self::decode_state(next_chr)?,
            Move(param)                     => Self::decode_move(next_chr, param)?,
            Line(param)                     => Self::decode_line(next_chr, param)?,
            BezierCurve(param)              => Self::decode_bezier_curve(next_chr, param)?,
            LineStyleWidth(param)           => Self::decode_line_width(next_chr, param)?,
            LineStyleWidthPixels(param)     => Self::decode_line_width_pixels(next_chr, param)?,
            LineStyleJoin(param)            => Self::decode_line_style_join(next_chr, param)?,
            LineStyleCap(param)             => Self::decode_line_style_cap(next_chr, param)?,
            WindingRule                     => Self::decode_winding_rule(next_chr)?,
            DashLength(param)               => Self::decode_dash_length(next_chr, param)?,
            DashOffset(param)               => Self::decode_dash_offset(next_chr, param)?,
            ClearCanvas(param)              => Self::decode_clear_canvas(next_chr, param)?,
            ColorStroke(param)              => Self::decode_color_stroke(next_chr, param)?,
            ColorFill(param)                => Self::decode_color_fill(next_chr, param)?,
            ColorTexture(id, param)         => Self::decode_color_texture(next_chr, id, param)?,
            ColorGradient(id, param)        => Self::decode_color_gradient(next_chr, id, param)?,
            ColorTransform(param)           => Self::decode_color_transform(next_chr, param)?,
            BlendMode(param)                => Self::decode_blend_mode(next_chr, param)?,
            TransformHeight(param)          => Self::decode_transform_height(next_chr, param)?,
            TransformCenter(param)          => Self::decode_transform_center(next_chr, param)?,
            TransformMultiply(param)        => Self::decode_transform_multiply(next_chr, param)?,
            NewLayerU32(param)              => Self::decode_new_layer_u32(next_chr, param)?,
            NewLayerBlendU32(param)         => Self::decode_new_layer_blend_u32(next_chr, param)?,
            NewLayer(param)                 => Self::decode_new_layer(next_chr, param)?,
            NewLayerBlend(layer, blend)     => Self::decode_new_layer_blend(next_chr, layer, blend)?,
            SwapLayers(layer1, param)       => Self::decode_swap_layers(next_chr, layer1, param)?,
            NewSprite(param)                => Self::decode_new_sprite(next_chr, param)?,
            SpriteDraw(param)               => Self::decode_sprite_draw(next_chr, param)?,
            SpriteTransform                 => Self::decode_sprite_transform(next_chr)?,
            SpriteTransformTranslate(param) => Self::decode_sprite_transform_translate(next_chr, param)?,
            SpriteTransformScale(param)     => Self::decode_sprite_transform_scale(next_chr, param)?,
            SpriteTransformRotate(param)    => Self::decode_sprite_transform_rotate(next_chr, param)?,
            SpriteTransformTransform(param) => Self::decode_sprite_transform_transform(next_chr, param)?,
            FontDrawing                                         => Self::decode_font_drawing(next_chr)?,
            FontDrawText(font_id, string_decode, coords)        => Self::decode_font_draw_text(next_chr, font_id, string_decode, coords)?,
            FontBeginLayout(param)                              => Self::decode_font_begin_layout(next_chr, param)?,
            FontOp(font_id)                                     => Self::decode_font_op(next_chr, font_id)?,
            FontOpSize(font_id, size)                           => Self::decode_font_op_size(next_chr, font_id, size)?,
            FontOpData(font_id)                                 => Self::decode_font_op_data(next_chr, font_id)?,
            FontOpTtf(font_id, bytes)                           => Self::decode_font_data_ttf(next_chr, font_id, bytes)?,
            FontOpLayoutText(font_id, string)                   => Self::decode_font_op_layout(next_chr, font_id, string)?,
            FontOpDrawGlyphs(font_id, glyphs)                   => Self::decode_font_op_glyphs(next_chr, font_id, glyphs)?,
            TextureOp(texture_id)                               => Self::decode_texture_op(next_chr, texture_id)?,
            TextureOpCreate(texture_id, param)                  => Self::decode_texture_create(next_chr, texture_id, param)?,
            TextureOpSetBytes(texture_id, param, bytes)         => Self::decode_texture_set_bytes(next_chr, texture_id, param, bytes)?,
            TextureOpFillTransparency(texture_id, param)        => Self::decode_texture_fill_transparency(next_chr, texture_id, param)?,
            GradientOp(gradient_id)                             => Self::decode_gradient_op(next_chr, gradient_id)?,     
            GradientOpNew(gradient_id, param)                   => Self::decode_gradient_new(next_chr, gradient_id, param)?,
            GradientOpAddStop(gradient_id, param)               => Self::decode_gradient_add_stop(next_chr, gradient_id, param)?,
        };
        self.state = next_state;
        Ok(result)
    }
pub fn decode ( & mut self , next_chr : char ) -> Result < Option < Draw > , DecoderError > { use self :: DecoderState :: * ; // Next state depends on the character and the current state let mut state = DecoderState :: Error ; mem :: swap ( & mut self . state , & mut state ) ; let ( next_state , result ) = match state { None => Self :: decode_none ( next_chr ) ? , Error => Err ( DecoderError :: IsInErrorState ) ? , New => Self :: decode_new ( next_chr ) ? , LineStyle => Self :: decode_line_style ( next_chr ) ? , Dash => Self :: decode_dash ( next_chr ) ? , Color => Self :: decode_color ( next_chr ) ? , Sprite => Self :: decode_sprite ( next_chr ) ? , Transform => Self :: decode_transform ( next_chr ) ? , State => Self :: decode_state ( next_chr ) ? , Move ( param ) => Self :: decode_move ( next_chr , param ) ? , Line ( param ) => Self :: decode_line ( next_chr , param ) ? , BezierCurve ( param ) => Self :: decode_bezier_curve ( next_chr , param ) ? , LineStyleWidth ( param ) => Self :: decode_line_width ( next_chr , param ) ? , LineStyleWidthPixels ( param ) => Self :: decode_line_width_pixels ( next_chr , param ) ? , LineStyleJoin ( param ) => Self :: decode_line_style_join ( next_chr , param ) ? , LineStyleCap ( param ) => Self :: decode_line_style_cap ( next_chr , param ) ? , WindingRule => Self :: decode_winding_rule ( next_chr ) ? , DashLength ( param ) => Self :: decode_dash_length ( next_chr , param ) ? , DashOffset ( param ) => Self :: decode_dash_offset ( next_chr , param ) ? , ClearCanvas ( param ) => Self :: decode_clear_canvas ( next_chr , param ) ? , ColorStroke ( param ) => Self :: decode_color_stroke ( next_chr , param ) ? , ColorFill ( param ) => Self :: decode_color_fill ( next_chr , param ) ? , ColorTexture ( id , param ) => Self :: decode_color_texture ( next_chr , id , param ) ? , ColorGradient ( id , param ) => Self :: decode_color_gradient ( next_chr , id , param ) ? , ColorTransform ( param ) => Self :: decode_color_transform ( next_chr , param ) ? , BlendMode ( param ) => Self :: decode_blend_mode ( next_chr , param ) ? , TransformHeight ( param ) => Self :: decode_transform_height ( next_chr , param ) ? , TransformCenter ( param ) => Self :: decode_transform_center ( next_chr , param ) ? , TransformMultiply ( param ) => Self :: decode_transform_multiply ( next_chr , param ) ? , NewLayerU32 ( param ) => Self :: decode_new_layer_u32 ( next_chr , param ) ? , NewLayerBlendU32 ( param ) => Self :: decode_new_layer_blend_u32 ( next_chr , param ) ? , NewLayer ( param ) => Self :: decode_new_layer ( next_chr , param ) ? , NewLayerBlend ( layer , blend ) => Self :: decode_new_layer_blend ( next_chr , layer , blend ) ? , SwapLayers ( layer1 , param ) => Self :: decode_swap_layers ( next_chr , layer1 , param ) ? , NewSprite ( param ) => Self :: decode_new_sprite ( next_chr , param ) ? , SpriteDraw ( param ) => Self :: decode_sprite_draw ( next_chr , param ) ? , SpriteTransform => Self :: decode_sprite_transform ( next_chr ) ? , SpriteTransformTranslate ( param ) => Self :: decode_sprite_transform_translate ( next_chr , param ) ? , SpriteTransformScale ( param ) => Self :: decode_sprite_transform_scale ( next_chr , param ) ? , SpriteTransformRotate ( param ) => Self :: decode_sprite_transform_rotate ( next_chr , param ) ? , SpriteTransformTransform ( param ) => Self :: decode_sprite_transform_transform ( next_chr , param ) ? , FontDrawing => Self :: decode_font_drawing ( next_chr ) ? , FontDrawText ( font_id , string_decode , coords ) => Self :: decode_font_draw_text ( next_chr , font_id , string_decode , coords ) ? , FontBeginLayout ( param ) => Self :: decode_font_begin_layout ( next_chr , param ) ? , FontOp ( font_id ) => Self :: decode_font_op ( next_chr , font_id ) ? , FontOpSize ( font_id , size ) => Self :: decode_font_op_size ( next_chr , font_id , size ) ? , FontOpData ( font_id ) => Self :: decode_font_op_data ( next_chr , font_id ) ? , FontOpTtf ( font_id , bytes ) => Self :: decode_font_data_ttf ( next_chr , font_id , bytes ) ? , FontOpLayoutText ( font_id , string ) => Self :: decode_font_op_layout ( next_chr , font_id , string ) ? , FontOpDrawGlyphs ( font_id , glyphs ) => Self :: decode_font_op_glyphs ( next_chr , font_id , glyphs ) ? , TextureOp ( texture_id ) => Self :: decode_texture_op ( next_chr , texture_id ) ? , TextureOpCreate ( texture_id , param ) => Self :: decode_texture_create ( next_chr , texture_id , param ) ? , TextureOpSetBytes ( texture_id , param , bytes ) => Self :: decode_texture_set_bytes ( next_chr , texture_id , param , bytes ) ? , TextureOpFillTransparency ( texture_id , param ) => Self :: decode_texture_fill_transparency ( next_chr , texture_id , param ) ? , GradientOp ( gradient_id ) => Self :: decode_gradient_op ( next_chr , gradient_id ) ? , GradientOpNew ( gradient_id , param ) => Self :: decode_gradient_new ( next_chr , gradient_id , param ) ? , GradientOpAddStop ( gradient_id , param ) => Self :: decode_gradient_add_stop ( next_chr , gradient_id , param ) ? , } ; self . state = next_state ; Ok ( result ) }
Decodes a character, returning the next Draw operation if there is one
Decodes a character returning the next Draw operation if there is one
&mut self
next_chr
char