[][src]Trait rio::AsIoVecMut

pub trait AsIoVecMut { }

We use this internally as a way of communicating that for certain operations, we cannot accept a reference into read-only memory, like for reads.

If your compilation fails because of something related to this, it's because you are trying to use memory as a destination for a read that could never actually be written to anyway, which the compiler may place in read-only memory in your process that cannot be written to by anybody.

Examples

This will cause the following code to break, which would have caused an IO error anyway due to trying to write to static read-only memory:

This example deliberately fails to compile
let ring = rio::new().unwrap();
let file = std::fs::File::open("failure").unwrap();

// the following buffer is placed in
// static, read-only memory and would
// never be valid to write to
let buffer: &[u8] = b"this is read-only";

// this fails to compile, because &[u8]
// does not implement `AsIoVecMut`:
ring.read_at(&file, &buffer, 0).unwrap();

which can be fixed by making it a mutable slice:

let ring = rio::new().unwrap();
let file = std::fs::File::open("failure").unwrap();

// the following buffer is placed in
// readable and writable memory, due to
// its mutability
let buffer: &mut [u8] = &mut [0; 42];

// this now works
ring.read_at(&file, &buffer, 0).wait();

Implementors

impl<A: ?Sized + AsMut<[u8]>> AsIoVecMut for A[src]

Loading content...