Thank you for your complete response.
Now I was able to understand this issue which is not so clearly exposed in the documentation.
So the correct Execution would produce:
file 'my_text_file.txt': created.
file 'my_text_file.txt': written.
file 'my_text_file.txt': read.
Report (Code: '0'): 'rd fl: 'File { fd: 3, path: "/playground/my_text_file.txt", read: true, write: false }'
cnk sz: '32'
chunk (sz: '32'):
'[49, 46, 32, 108, 105, 110, 101, 32, 116, 101, 120, 116, 32, 102, 105, 108, 101, 32, 99, 111, 110, 116, 101, 110, 116, 46, 10, 50, 46, 32, 108, 105]'
cnk sz: '32'
chunk (sz: '32'):
'[110, 101, 32, 116, 101, 120, 116, 32, 102, 105, 108, 101, 32, 99, 111, 110, 116, 101, 110, 116, 46, 10, 51, 46, 32, 108, 105, 110, 101, 32, 116, 101]'
cnk sz: '32'
chunk (sz: '32'):
'[120, 116, 32, 102, 105, 108, 101, 32, 99, 111, 110, 116, 101, 110, 116, 46, 10, 52, 46, 32, 108, 105, 110, 101, 32, 116, 101, 120, 116, 32, 102, 105]'
cnk sz: '32'
chunk (sz: '32'):
'[108, 101, 32, 99, 111, 110, 116, 101, 110, 116, 46, 10, 53, 46, 32, 108, 105, 110, 101, 32, 116, 101, 120, 116, 32, 102, 105, 108, 101, 32, 99, 111]'
cnk sz: '32'
chunk (sz: '7'):
'[110, 116, 101, 110, 116, 46, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]'
'
spl cntnt:
"1. line text file content.\n2. line text file content.\n3. line text file content.\n4. line text file content.\n5. line text file content.\n"
And even I could draw some improvements from your comment about the io::ErrorKind::Interrupted
and the chunk.truncate(bytes_read)
.
The chunk.truncate()
becomes quite important with a big chunk_size
on a small file. But the variable chunk_size
would give performance improvements on big files > 8192 Bytes.