use std::io;
use std::io::Write;
use crate::runtime::OperationByteSink;
pub(in crate::formats::http) struct BoundedBodyWriter {
sink: OperationByteSink,
}
impl BoundedBodyWriter {
#[must_use]
#[inline]
pub(in crate::formats::http) fn new(max_bytes: usize) -> Self {
Self {
sink: OperationByteSink::new(max_bytes),
}
}
#[must_use]
#[inline]
pub(in crate::formats::http) fn into_string(self) -> Option<String> {
self.sink.into_string()
}
}
impl Write for BoundedBodyWriter {
fn write(&mut self, buffer: &[u8]) -> io::Result<usize> {
self.sink.write(buffer)
}
#[inline(always)]
fn flush(&mut self) -> io::Result<()> {
self.sink.flush()
}
}