falco_event/types/format/cstr.rs
1use crate::types::format::ByteBufFormatter;
2use std::ffi::CStr;
3use std::fmt::{Debug, Formatter};
4
5/// Falco-style CStr formatter
6///
7/// Formats the string like a byte buffer (replacing non-ASCII characters with `.`).
8/// See [`ByteBufFormatter`] for the implementation.
9pub struct CStrFormatter<'a>(pub &'a CStr);
10
11impl Debug for CStrFormatter<'_> {
12 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
13 Debug::fmt(&ByteBufFormatter(self.0.to_bytes()), f)
14 }
15}