[][src]Trait positioned_io_preview::WriteAt

pub trait WriteAt {
    fn write_at(&mut self, pos: u64, buf: &[u8]) -> Result<usize>;
fn flush(&mut self) -> Result<()>; fn write_all_at(&mut self, pos: u64, buf: &[u8]) -> Result<()> { ... } }

Trait for writing bytes at an offset.

Implementations should be able to write bytes at an offset, without changing any sort of write position. Self should not change at all.

When writing beyond the end of the underlying object it is extended and intermediate bytes are filled with the value 0.

Examples

use std::fs::OpenOptions;
use positioned_io::WriteAt;

let mut file = OpenOptions::new().write(true).open("tests/pi.txt")?;

// write some bytes
let bytes_written = file.write_at(2, b"1415926535897932384626433")?;

Required Methods

Writes bytes from a buffer to an offset, returning the number of bytes written.

This function may write fewer bytes than the size of buf, for example if it is interrupted.

See Write::write() for details.

Flush this writer, ensuring that any intermediately buffered data reaches its destination.

This should rarely do anything, since buffering is not very useful for positioned writes.

This should be equivalent to Write::flush(), so it does not actually sync changes to disk when writing a File. Use File::sync_data() instead.

Provided Methods

Writes a complete buffer at an offset.

Errors if it could not write the entire buffer.

See Write::write_all() for details.

Implementations on Foreign Types

impl WriteAt for File
[src]

impl<'a> WriteAt for &'a mut [u8]
[src]

impl WriteAt for Vec<u8>
[src]

impl<'a, W: WriteAt + ?Sized> WriteAt for &'a mut W
[src]

impl<'a, W: WriteAt> WriteAt for &'a RefCell<W>
[src]

Implementors

impl WriteAt for RandomAccessFile
[src]

impl<I: WriteAt> WriteAt for Slice<I>
[src]

impl<I: WriteAt, E: ByteOrder> WriteAt for ByteIo<I, E>
[src]