MCPcopy Create free account
hub / github.com/BillyDM/Firewheel / try_error_with

Method try_error_with

crates/firewheel-core/src/log.rs:220–235  ·  view source on GitHub ↗

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))

Source from the content-addressed store, hash-verified

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`].

Callers 1

validate_outputFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected