Decreases the reference count by 1. # Returns - `Ok(())` if the reference count was successfully decreased. - `Err(BlockError::ReferenceCountError)` if the reference count is already zero. # Errors This method will return an error if the reference count is already zero, as it's not possible to decrease it further.
(&mut self)
| 245 | /// This method will return an error if the reference count is already zero, |
| 246 | /// as it's not possible to decrease it further. |
| 247 | pub fn decrease_ref_count(&mut self) -> Result<(), BlockError> { |
| 248 | if self.ref_count > 0 { |
| 249 | self.ref_count -= 1; |
| 250 | Ok(()) |
| 251 | } else { |
| 252 | error!( |
| 253 | "Reference counter is already zero, trying to dereference once more which should not be possible.." |
| 254 | ); |
| 255 | Err(BlockError::ReferenceCountError) |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | /// A thread-safe, shared-ownership wrapper for `PhysicalTokenBlock`. |