use std::io;
use std::io::Write;
pub(crate) struct JsonLexemeLengthWriter {
len: usize,
}
impl JsonLexemeLengthWriter {
#[must_use]
#[inline(always)]
pub(crate) const fn new() -> Self {
Self { len: 0 }
}
#[must_use]
#[inline(always)]
pub(crate) const fn len(&self) -> usize {
self.len
}
}
impl Write for JsonLexemeLengthWriter {
fn write(&mut self, input: &[u8]) -> io::Result<usize> {
self.len = self
.len
.checked_add(input.len())
.ok_or_else(|| io::Error::from(io::ErrorKind::FileTooLarge))?;
Ok(input.len())
}
#[inline(always)]
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}