use std::borrow::Cow;
use crate::LogSafeText;
use super::HttpRedactor;
use crate::http::internal::{
BoundedLogWriter,
markers,
};
impl HttpRedactor {
pub(super) fn diagnostic_input_exceeded(&self, input_bytes: usize) -> bool {
input_bytes
> self.policy().limits().diagnostic_event().max_input_bytes()
}
pub(super) fn diagnostic_limit_exceeded() -> LogSafeText<'static> {
LogSafeText::from_escaped(Cow::Borrowed(
markers::DIAGNOSTIC_LIMIT_EXCEEDED,
))
}
pub(super) fn finish_diagnostic(
&self,
text: String,
) -> LogSafeText<'static> {
let mut writer = BoundedLogWriter::new(
self.policy().limits().diagnostic_event().max_output_bytes(),
false,
);
let _ = writer.write_str(&text);
let (text, _) = writer.finish();
LogSafeText::from_escaped(Cow::Owned(text))
}
}