pub fn remove(&mut self, key: &Key) -> Result<Option<Value>, SerializedError> {
        if let Some(old_value) = self.map.remove(&key) {
            match &mut self.cfg.format {
                Format::Text(before_write_callback, _) => {
                    let mut line = file_line_of_remove(key, &mut self.cfg.integrity)?;
                    if let Some(f) = before_write_callback {
                        f(&mut line);
                    }
                    self.file_worker.write_string(line);
                    self.update_index_when_remove(key, &old_value);
                    return Ok(Some(old_value));
                }
                Format::Bin(before_write_callback, _) => {
                    let mut block = bin_file_block_of_remove(key, &mut self.cfg.integrity)?;
                    if let Some(f) = before_write_callback {
                        f(&mut block);
                    }
                    self.file_worker.write_bytes(block);
                    self.update_index_when_remove(key, &old_value);
                    return Ok(Some(old_value));
                },
            }
        }

        Ok(None)
    }
/// Remove value by key.
/// Insert into the map will immediately, and to disk later in a background thread.
///
/// # Errors
///
/// Error can by returned only if serde_json::to_string() return error:
/// Serialization can fail if 'Key' or 'Value' s implementation of `Serialize` decides to
/// fail, or if 'Key' or 'Value' contains a map with non-string keys.
///
Remove value by key.
Insert into the map will immediately, and to disk later in a background thread.
Remove value by key . Insert into the map will immediately and to disk later in a background thread .
pub fn remove(&mut self, key: &Key) -> Result<Option<Value>, SerializedError> {
        if let Some(old_value) = self.map.remove(&key) {
            match &mut self.cfg.format {
                Format::Text(before_write_callback, _) => {
                    let mut line = file_line_of_remove(key, &mut self.cfg.integrity)?;
                    if let Some(f) = before_write_callback {
                        f(&mut line);
                    }
                    self.file_worker.write_string(line);
                    self.update_index_when_remove(key, &old_value);
                    return Ok(Some(old_value));
                }
                Format::Bin(before_write_callback, _) => {
                    let mut block = bin_file_block_of_remove(key, &mut self.cfg.integrity)?;
                    if let Some(f) = before_write_callback {
                        f(&mut block);
                    }
                    self.file_worker.write_bytes(block);
                    self.update_index_when_remove(key, &old_value);
                    return Ok(Some(old_value));
                },
            }
        }
        Ok(None)
    }
pub fn remove ( & mut self , key : & Key ) -> Result < Option < Value > , SerializedError > { if let Some ( old_value ) = self . map . remove ( & key ) { match & mut self . cfg . format { Format :: Text ( before_write_callback , _ ) => { let mut line = file_line_of_remove ( key , & mut self . cfg . integrity ) ? ; if let Some ( f ) = before_write_callback { f ( & mut line ) ; } self . file_worker . write_string ( line ) ; self . update_index_when_remove ( key , & old_value ) ; return Ok ( Some ( old_value ) ) ; } Format :: Bin ( before_write_callback , _ ) => { let mut block = bin_file_block_of_remove ( key , & mut self . cfg . integrity ) ? ; if let Some ( f ) = before_write_callback { f ( & mut block ) ; } self . file_worker . write_bytes ( block ) ; self . update_index_when_remove ( key , & old_value ) ; return Ok ( Some ( old_value ) ) ; } , } } Ok ( None ) }
Remove value by key.
Remove value by key .
&mut self
key
&Key
&mut self
key
&Key
errors
Error can by returned only if serde_json::to_string() return error:
Serialization can fail if 'Key' or 'Value' s implementation of `Serialize` decides to
fail, or if 'Key' or 'Value' contains a map with non-string keys.
Error can by returned only if serde_json :: to_string () return error : Serialization can fail if ' Key ' or ' Value ' s implementation of ` Serialize ` decides to fail or if ' Key ' or ' Value ' contains a map with non - string keys .