tracing-trace: introduce TraceWriter, trace now only exposes the channel

This commit is contained in:
Louis Dureuil 2024-01-31 17:44:54 +01:00
parent 0f327f2821
commit 0e7a411d4d
No known key found for this signature in database
3 changed files with 36 additions and 8 deletions

View file

@ -9,11 +9,25 @@ pub mod processor;
pub use error::Error;
pub struct Trace<W: Write> {
pub struct TraceWriter<W: Write> {
writer: W,
receiver: tokio::sync::mpsc::UnboundedReceiver<Entry>,
}
pub struct Trace {
receiver: tokio::sync::mpsc::UnboundedReceiver<Entry>,
}
impl Trace {
pub fn into_receiver(self) -> tokio::sync::mpsc::UnboundedReceiver<Entry> {
self.receiver
}
pub fn into_writer<W: Write>(self, writer: W) -> TraceWriter<W> {
TraceWriter { writer, receiver: self.receiver }
}
}
pub struct TraceReader<R: Read> {
reader: R,
}