#[non_exhaustive]pub struct Timestamper { /* private fields */ }Expand description
Configured line-timestamping engine. Cheap to construct (no IO until
prefix_lines is called). Marked #[non_exhaustive] for future evolution.
§Example
use rusty_ts::{TimestamperBuilder, Format, TimezoneSource};
use std::io::Cursor;
let ts = TimestamperBuilder::new()
.format(Format::Strftime("[%H:%M:%S]".into()))
.utc(true)
.build()
.unwrap();
let input = Cursor::new(b"hello\n".to_vec());
let chunks: Vec<Vec<u8>> = ts
.prefix_lines(input)
.collect::<Result<_, _>>()
.unwrap();
assert!(chunks[0].ends_with(b" hello\n"));Implementations§
Source§impl Timestamper
impl Timestamper
Sourcepub fn prefix_lines<R: BufRead>(
&self,
reader: R,
) -> impl Iterator<Item = Result<Vec<u8>, Error>>
pub fn prefix_lines<R: BufRead>( &self, reader: R, ) -> impl Iterator<Item = Result<Vec<u8>, Error>>
Drive a BufRead line source through the
timestamper. Returns an iterator over byte-typed output chunks
(Vec<u8>); non-UTF-8 payload bytes pass through unchanged per
FR-011.
The returned iterator yields one Result<Vec<u8>, io::Error> per
input line. Each chunk is the timestamp prefix followed by a
two-space separator followed by the payload (including any
trailing newline that was present in the input).
Sourcepub fn prefix_string_lines<I>(&self, lines: I) -> impl Iterator<Item = String>where
I: IntoIterator<Item = String>,
pub fn prefix_string_lines<I>(&self, lines: I) -> impl Iterator<Item = String>where
I: IntoIterator<Item = String>,
Convenience adapter for callers who already have UTF-8 String
lines. Returns prefixed String chunks. Non-UTF-8 input is impossible
at this surface — use prefix_lines if you need byte fidelity.
Sourcepub fn format_spec(&self) -> &str
pub fn format_spec(&self) -> &str
Return the effective strftime format spec — either the builder’s supplied spec or the moreutils default. Used by the iterator implementations.
Sourcepub fn compat(&self) -> CompatibilityMode
pub fn compat(&self) -> CompatibilityMode
Return the configured compatibility mode.
Sourcepub fn timezone(&self) -> &TimezoneSource
pub fn timezone(&self) -> &TimezoneSource
Return a reference to the configured timezone source.
Sourcepub fn elapsed_anchor(&self) -> ElapsedAnchor
pub fn elapsed_anchor(&self) -> ElapsedAnchor
Return the configured elapsed-time anchor.
Trait Implementations§
Source§impl Clone for Timestamper
impl Clone for Timestamper
Source§fn clone(&self) -> Timestamper
fn clone(&self) -> Timestamper
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more