fn decode(mut self, chr: char) -> Result<DecodeString, DecoderError> {
        // Decode or fetch the length of the string
        let length = match self.length {
            PartialResult::MatchMore(so_far)    => {
                self.length = CanvasDecoder::decode_compact_id(chr, so_far)?;

                if let &PartialResult::FullMatch(0) = &self.length {
                    self.string_encoding = PartialResult::FullMatch(String::new());
                }
                return Ok(self);
            }

            PartialResult::FullMatch(length)    => {
                self.length = PartialResult::FullMatch(length);
                length as usize
            }
        };

        // Try to decode the rest of the string
        match self.string_encoding {
            PartialResult::FullMatch(string)    => {
                // Nothing to do
                self.string_encoding = PartialResult::FullMatch(string);
            }

            PartialResult::MatchMore(mut string)    => {
                string.push(chr);

                if string.len() >= length {
                    self.string_encoding = PartialResult::FullMatch(string);
                } else {
                    self.string_encoding = PartialResult::MatchMore(string);
                }
            }
        }

        Ok(self)
    }
///
/// Decodes a single character and returns the new state of the decoder
///
Decodes a single character and returns the new state of the decoder
Decodes a single character and returns the new state of the decoder
fn decode(mut self, chr: char) -> Result<DecodeString, DecoderError> {
        // Decode or fetch the length of the string
        let length = match self.length {
            PartialResult::MatchMore(so_far)    => {
                self.length = CanvasDecoder::decode_compact_id(chr, so_far)?;
                if let &PartialResult::FullMatch(0) = &self.length {
                    self.string_encoding = PartialResult::FullMatch(String::new());
                }
                return Ok(self);
            }
            PartialResult::FullMatch(length)    => {
                self.length = PartialResult::FullMatch(length);
                length as usize
            }
        };
        // Try to decode the rest of the string
        match self.string_encoding {
            PartialResult::FullMatch(string)    => {
                // Nothing to do
                self.string_encoding = PartialResult::FullMatch(string);
            }
            PartialResult::MatchMore(mut string)    => {
                string.push(chr);
                if string.len() >= length {
                    self.string_encoding = PartialResult::FullMatch(string);
                } else {
                    self.string_encoding = PartialResult::MatchMore(string);
                }
            }
        }
        Ok(self)
    }
fn decode ( mut self , chr : char ) -> Result < DecodeString , DecoderError > { // Decode or fetch the length of the string let length = match self . length { PartialResult :: MatchMore ( so_far ) => { self . length = CanvasDecoder :: decode_compact_id ( chr , so_far ) ? ; if let & PartialResult :: FullMatch ( 0 ) = & self . length { self . string_encoding = PartialResult :: FullMatch ( String :: new ( ) ) ; } return Ok ( self ) ; } PartialResult :: FullMatch ( length ) => { self . length = PartialResult :: FullMatch ( length ) ; length as usize } } ; // Try to decode the rest of the string match self . string_encoding { PartialResult :: FullMatch ( string ) => { // Nothing to do self . string_encoding = PartialResult :: FullMatch ( string ) ; } PartialResult :: MatchMore ( mut string ) => { string . push ( chr ) ; if string . len ( ) >= length { self . string_encoding = PartialResult :: FullMatch ( string ) ; } else { self . string_encoding = PartialResult :: MatchMore ( string ) ; } } } Ok ( self ) }
Decodes a single character and returns the new state of the decoder
Decodes a single character and returns the new state of the decoder
mut self
chr
char