Log an error message into the given string. This string is guaranteed to be empty and have an allocated capacity of at least [`RealtimeLogger::max_message_length`].
(&mut self, f: impl FnOnce(&mut String))
| 218 | /// This string is guaranteed to be empty and have an allocated capacity |
| 219 | /// of at least [`RealtimeLogger::max_message_length`]. |
| 220 | pub fn try_error_with(&mut self, f: impl FnOnce(&mut String)) -> Result<(), RealtimeLogError> { |
| 221 | let Some(mut slot) = self.error_cons.try_pop() else { |
| 222 | self.shared_state |
| 223 | .not_enough_slots_occurred |
| 224 | .store(true, Ordering::Relaxed); |
| 225 | return Err(RealtimeLogError::OutOfSlots); |
| 226 | }; |
| 227 | |
| 228 | slot.clear(); |
| 229 | |
| 230 | (f)(&mut slot); |
| 231 | |
| 232 | let _ = self.error_prod.try_push(slot); |
| 233 | |
| 234 | Ok(()) |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /// The main thread counterpart to a [`RealtimeLogger`]. |