Hi. I have a library which has to emit some binary data occasionally (with a unique target for each such data). But the data shouldn't be just logged to a console or whatever, it needs to be written to a file.
I have been reading the documentation for some time, and it's clear for me that I have to write my own layer which would consume that data, but that doesn't turn out to be a problem.
Rather, it's not quite simple to "access" the data from tracing. Writing a visitor or layer only grants access to erased objects which only implement Debug and Display.
I'm aware of valuable feature, but I'm not quite sure about: it seems that Valuable::Listable(&dyn Listable) has a very limited API, and only allows me effectively print it . Am I wrong about that?
So, is there a sane way in tracing to save and consume such data in the way I described?
Edit: Do you mean the valuable crate? If so I think you can call .visit() on the &dyn Listable (Listable has Valuable as super trait) and then the type implementing Visit that you call .visit() with will get .visit_value() called once for each element or .visit_primitive_slice() once with all list items.
Tracing output is generally meant for human consumption, either directly or through aggregators and statistical tools. tracing (the crate) builds around that assumption. Humans are not particularly good at understanding binary data, to put it mildly; tracing expects that all values will have some human-readable representation, available through the Debug or Display traits.
I'm sure it's possible to bend tracing into handling your data-delivery needs anyways, but I have to ask: what is this data, and why are you hoping that tracing will be the best way to handle it?