#io #statistics #object #wrap #io-operations #logging #io-tracing

io_wrapper_statistics

Wrap an I/O object and collect statistics about I/O operations

2 releases

0.1.1 Sep 11, 2021
0.1.0 Sep 11, 2021

#659 in Debugging

MIT/Apache

17KB
309 lines

io_wrapper_statistics

This library is a development tool that wraps an I/O object and provides statistics on how often each of the I/O methods are called, as well as a means of logging the I/O calls and their results.


lib.rs:

We wrap most methods of Read, including provided ones, and pass calls through to the inner I/O object. The I/O operation log and statistics are only explicitly updated in the [Read::read()] function, as it is expected that the other methods are implemented with it. Notably, we do not passthrough [Read::bytes()], [Read::chain()], and [Read::take()] as the structs they return have private implementation details that we need to see to have correct type generics. However, for this reason, we do not expect other Read implementations to have their own implementations either, so this shouldn't be an issue. Passthrough for the inner_io read call that increments a call counter and appends a IopResults::Read object to the log. We wrap all methods of Seek, including provided ones, and pass calls through to the inner I/O object. The I/O operation log and statistics are only explicitly updated in the [Seek::seek()] function, as it is expected that the other methods are implemented with it. Passthrough for the inner_io seek call that increments a call counter and appends a IopResults::Seek object to the log. We wrap all methods of Write, including provided ones, and pass calls through to the inner I/O object. The I/O operation log and statistics are explicitly updated in the [Write::write()] and [Write::flush()] functions, as it is expected that the other methods are implemented with them. Passthrough for the inner_io write call that increments a call counter and appends a IopResults::Write object to the log. Passthrough for the inner_io write call that increments a call counter and appends a IopResults::Flush object to the log.

Dependencies

~155KB