Create a new implementation for the writev method in the Producer struct and the readv method in the Consumer struct. The methods should adhere to the following specifications:
Requirements for writev in Producer:
Accepts a slice of byte slices (&[&[u8]]) as input.
Writes all the bytes from the provided slices into the underlying ring buffer.
Should return the total number of bytes written or an error if the buffer is shut down or if it cannot accommodate the data.
Update the pollee state after writing the data in a way that reflects the new state of the ring buffer.
Requirements for readv in Consumer:
Accepts a mutable slice of byte slices (&mut [&mut [u8]]) as input.
Reads data from the underlying ring buffer into the provided slices, filling them in sequence.
Should return the total number of bytes read or an error if the buffer is shut down or if there is not enough data to read.
Update the pollee state after reading the data to accurately reflect the new state of the ring buffer.
Note:
Both implementations should ensure proper synchronization in access to the ring buffer.
Follow the same error handling convention as established in the read and write methods.
Ensure that both the writev and readv methods are thoroughly tested by creating appropriate test cases following the structure of existing tests in the module.
Solution Location:
Implement the required methods in the app/producer.rs and app/consumer.rs files respectively.