pub struct Encoder<W: Write> { /* private fields */ }Expand description
Encode a stream of LogMsg into an .rrd file.
When dropped, it will automatically insert an end-of-stream marker, if that wasn’t already done manually.
Implementations§
Source§impl Encoder<Vec<u8>>
impl Encoder<Vec<u8>>
pub fn local() -> Result<Self, EncodeError>
Sourcepub fn encode(
messages: impl IntoIterator<Item = ChunkResult<impl Borrow<LogMsg>>>,
) -> Result<Vec<u8>, EncodeError>
pub fn encode( messages: impl IntoIterator<Item = ChunkResult<impl Borrow<LogMsg>>>, ) -> Result<Vec<u8>, EncodeError>
All-in-one helper to encode a stream of LogMsgs into an actual RRD stream.
This always uses the local version and its default encoding options.
Returns the encoded data in a newly allocated vector.
Source§impl<W: Write> Encoder<W>
impl<W: Write> Encoder<W>
Sourcepub fn new_eager(
version: CrateVersion,
options: EncodingOptions,
write: W,
) -> Result<Self, EncodeError>
pub fn new_eager( version: CrateVersion, options: EncodingOptions, write: W, ) -> Result<Self, EncodeError>
Creates a new Encoder.
This will immediately write the StreamHeader to the output stream as part of
initialization (hence _eager).
There is no _lazy version. Make one if you need one.
Sourcepub fn append(&mut self, message: &LogMsg) -> Result<u64, EncodeError>
pub fn append(&mut self, message: &LogMsg) -> Result<u64, EncodeError>
Returns the size in bytes of the encoded data.
Sourcepub fn extend(
&mut self,
messages: impl IntoIterator<Item = ChunkResult<impl Borrow<LogMsg>>>,
) -> Result<u64, EncodeError>
pub fn extend( &mut self, messages: impl IntoIterator<Item = ChunkResult<impl Borrow<LogMsg>>>, ) -> Result<u64, EncodeError>
Returns the size in bytes of the encoded data.
Instructs the encoder to not emit a footer at the end of the stream.
This cannot be reverted.
Returns the span and uncompressed size in bytes of the encoded data.
⚠️ This implies Self::do_not_emit_footer. ⚠️
§Safety
message must respect the global settings of the encoder (e.g. the compression used),
otherwise the resulting RRD stream will be corrupt and unreadable.
Like Self::finish, but appends the specified, custom RRD footer.
§Safety
This is extremely unsafe and only makes sense if you know exactly what you are doing.
This is generally only useful when manipulating existing footers and manifests directly,
like e.g. rerun rrd route does.
You can verify that the footer you produced is still deserializable using rerun rrd verify.
Sourcepub fn finish(&mut self) -> Result<(), EncodeError>
pub fn finish(&mut self) -> Result<(), EncodeError>
Appends an end-of-stream marker to the encoded bytes. Does not flush.
This is idempotent. This is called automatically on drop.
This end-of-stream marker is currently (seemingly?) relied on for:
- Tail mode (where the Viewer continuously poll reads from a file on disk).
- Concatenated RRD file streams (e.g.
cat *.rrd | rerun -).
pub fn flush_blocking(&mut self) -> Result<(), EncodeError>
pub fn into_inner(self) -> Result<W, EncodeError>
Source§impl<W: Write> Encoder<W>
impl<W: Write> Encoder<W>
Sourcepub fn encode_into(
version: CrateVersion,
options: EncodingOptions,
messages: impl IntoIterator<Item = ChunkResult<impl Borrow<LogMsg>>>,
write: &mut W,
) -> Result<u64, EncodeError>
pub fn encode_into( version: CrateVersion, options: EncodingOptions, messages: impl IntoIterator<Item = ChunkResult<impl Borrow<LogMsg>>>, write: &mut W, ) -> Result<u64, EncodeError>
All-in-one helper to encode a stream of LogMsgs into an actual RRD stream.
Returns the size in bytes of the encoded data.
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for Encoder<W>where
W: Freeze,
impl<W> RefUnwindSafe for Encoder<W>where
W: RefUnwindSafe,
impl<W> Send for Encoder<W>where
W: Send,
impl<W> Sync for Encoder<W>where
W: Sync,
impl<W> Unpin for Encoder<W>where
W: Unpin,
impl<W> UnsafeUnpin for Encoder<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for Encoder<W>where
W: UnwindSafe,
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request