pub fn compress_text(&mut self) -> Result<(), EncodingError> {
        match &self.text {
            OptCompressed::Uncompressed(s) => {
                let uncompressed_raw = s.as_bytes();
                let mut encoder = ZlibEncoder::new(Vec::new(), Compression::Fast);
                encoder
                    .write_all(&uncompressed_raw)
                    .map_err(|_| EncodingError::from(TextEncodingError::CompressionError))?;
                self.text = OptCompressed::Compressed(
                    encoder
                        .finish()
                        .map_err(|_| EncodingError::from(TextEncodingError::CompressionError))?,
                );
            }
            OptCompressed::Compressed(_) => {}
        }

        Ok(())
    }
/// Compresses the inner text, mutating its own state.
Compresses the inner text, mutating its own state.
Compresses the inner text mutating its own state .
pub fn compress_text(&mut self) -> Result<(), EncodingError> {
        match &self.text {
            OptCompressed::Uncompressed(s) => {
                let uncompressed_raw = s.as_bytes();
                let mut encoder = ZlibEncoder::new(Vec::new(), Compression::Fast);
                encoder
                    .write_all(&uncompressed_raw)
                    .map_err(|_| EncodingError::from(TextEncodingError::CompressionError))?;
                self.text = OptCompressed::Compressed(
                    encoder
                        .finish()
                        .map_err(|_| EncodingError::from(TextEncodingError::CompressionError))?,
                );
            }
            OptCompressed::Compressed(_) => {}
        }
        Ok(())
    }
pub fn compress_text ( & mut self ) -> Result < ( ) , EncodingError > { match & self . text { OptCompressed :: Uncompressed ( s ) => { let uncompressed_raw = s . as_bytes ( ) ; let mut encoder = ZlibEncoder :: new ( Vec :: new ( ) , Compression :: Fast ) ; encoder . write_all ( & uncompressed_raw ) . map_err ( | _ | EncodingError :: from ( TextEncodingError :: CompressionError ) ) ? ; self . text = OptCompressed :: Compressed ( encoder . finish ( ) . map_err ( | _ | EncodingError :: from ( TextEncodingError :: CompressionError ) ) ? , ) ; } OptCompressed :: Compressed ( _ ) => { } } Ok ( ( ) ) }
Compresses the inner text, mutating its own state.
Compresses the inner text mutating its own state .
&mut self