pub(super) struct LineBuffer {
pub(super) stdout: BytesMut,
stderr: BytesMut,
}Expand description
Collects the output of both pipes into whole lines for journald, which writes one entry per line.
A read chunk may end anywhere, in the middle of a line, between “\r” and
“\n” or inside a multi byte character. Keeping the incomplete tail until
the next chunk of the same pipe arrives avoids split lines and garbled
characters. A line which grows beyond LineBuffer::MAX_LINE is written
as a partial one, cut at a character boundary, and so is a line which
waits too long for its ending, see LineBuffer::flush.
Fields§
§stdout: BytesMut§stderr: BytesMutImplementations§
Source§impl LineBuffer
impl LineBuffer
fn tail(&mut self, pipe: Pipe) -> &mut BytesMut
Sourcepub(super) fn has_pending(&self, pipe: Pipe) -> bool
pub(super) fn has_pending(&self, pipe: Pipe) -> bool
Whether a line of the pipe waits for its ending.
Sourcepub(super) fn push<'a>(&mut self, pipe: Pipe, bytes: &'a [u8]) -> Vec<Line<'a>>
pub(super) fn push<'a>(&mut self, pipe: Pipe, bytes: &'a [u8]) -> Vec<Line<'a>>
Add a chunk and return the lines it completes. The whole lines of the chunk borrow it, only the end of a line which started in an earlier chunk and the start of one which continues in a later one get copied into the buffer of the pipe.
Sourcefn cut_long(tail: &mut BytesMut) -> Option<Line<'static>>
fn cut_long(tail: &mut BytesMut) -> Option<Line<'static>>
Cut a line which grew too long without its ending, see
LineBuffer::cut, and release the buffer once empty.
Sourcefn cut(tail: &mut BytesMut) -> Line<'static>
fn cut(tail: &mut BytesMut) -> Line<'static>
Cut the tail at a point which keeps an unfinished multi byte character and a “\r” waiting for its “\n” in the buffer. Invalid bytes are not held back, they would stay in front forever.
Sourcefn complete_len(bytes: &[u8]) -> usize
fn complete_len(bytes: &[u8]) -> usize
The length of the bytes without the unfinished multi byte character they end with, if any. Only the last character matters, which starts within the last three bytes if it is unfinished, an invalid byte in front of it does not.
Sourcefn shrink(tail: &mut BytesMut)
fn shrink(tail: &mut BytesMut)
A line longer than a read chunk leaves a large buffer behind, release it once drained. An idle container keeps at most a chunk of it.
Trait Implementations§
Source§impl Debug for LineBuffer
impl Debug for LineBuffer
Auto Trait Implementations§
impl Freeze for LineBuffer
impl RefUnwindSafe for LineBuffer
impl Send for LineBuffer
impl Sync for LineBuffer
impl Unpin for LineBuffer
impl UnsafeUnpin for LineBuffer
impl UnwindSafe for LineBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].