Skip to content

Commit 51245be

Browse files
roypatbonzini
authored andcommitted
chore: remove deprecated methods
The old `Read`/`Write` based APIs for operating on guest memory have been deprecated for a fairly long time now, and are superseceded by their `ReadVolatile`/`WriteVolatile` equivalents. The `fold` and friends functions have been deprecated for way longer. Various `.as_ptr` APIs in volatile_memory.rs are deprecated in favor of pointer guards. Let's clean up the crate and remove all of these. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
1 parent a2a3901 commit 51245be

File tree

6 files changed

+10
-799
lines changed

6 files changed

+10
-799
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
- \[[#311](https://github.com/rust-vmm/vm-memory/pull/311)\] Allow compiling without the ReadVolatile and WriteVolatile implementations
88

9+
### Removed
10+
11+
- \[[#307](https://github.com/rust-vmm/vm-memory/pull/304)\] Remove deprecated functions `Bytes::read_from`, `Bytes::read_exact_from`,
12+
`Bytes::write_to`, `Bytes::write_all_to`, `GuestMemory::as_slice`, `GuestMemory::as_slice_mut`, `GuestMemory::with_regions`,
13+
`GuestMemory::with_regions_mut`, `GuestMemory::map_and_fold`, `VolatileSlice::as_ptr`, `VolatileRef::as_ptr`, and
14+
`VolatileArrayRef::as_ptr`.
15+
916
## \[v0.16.1\]
1017

1118
### Added

src/bitmap/mod.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ pub type MS<'a, M> = BS<'a, <<M as GuestMemory>::R as GuestMemoryRegion>::B>;
109109
pub(crate) mod tests {
110110
use super::*;
111111

112-
use std::io::Cursor;
113112
use std::marker::PhantomData;
114113
use std::mem::size_of_val;
115114
use std::result::Result;
@@ -264,26 +263,6 @@ pub(crate) mod tests {
264263
.unwrap();
265264
dirty_offset += step;
266265

267-
// Test `read_from`.
268-
#[allow(deprecated)] // test of deprecated functions
269-
h.test_access(bytes, dirty_offset, BUF_SIZE, |m, addr| {
270-
assert_eq!(
271-
m.read_from(addr, &mut Cursor::new(&buf), BUF_SIZE).unwrap(),
272-
BUF_SIZE
273-
)
274-
})
275-
.unwrap();
276-
dirty_offset += step;
277-
278-
// Test `read_exact_from`.
279-
#[allow(deprecated)] // test of deprecated functions
280-
h.test_access(bytes, dirty_offset, BUF_SIZE, |m, addr| {
281-
m.read_exact_from(addr, &mut Cursor::new(&buf), BUF_SIZE)
282-
.unwrap()
283-
})
284-
.unwrap();
285-
dirty_offset += step;
286-
287266
// Test `store`.
288267
h.test_access(bytes, dirty_offset, size_of_val(&val), |m, addr| {
289268
m.store(val, addr, Ordering::Relaxed).unwrap()

src/bytes.rs

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! Define the `ByteValued` trait to mark that it is safe to instantiate the struct with random
1212
//! data.
1313
14-
use std::io::{Read, Write};
1514
use std::mem::{size_of, MaybeUninit};
1615
use std::result::Result;
1716
use std::slice::{from_raw_parts, from_raw_parts_mut};
@@ -277,72 +276,6 @@ pub trait Bytes<A> {
277276
self.read_slice(result.as_mut_slice(), addr).map(|_| result)
278277
}
279278

280-
/// Reads up to `count` bytes from an object and writes them into the container at `addr`.
281-
///
282-
/// Returns the number of bytes written into the container.
283-
///
284-
/// # Arguments
285-
/// * `addr` - Begin writing at this address.
286-
/// * `src` - Copy from `src` into the container.
287-
/// * `count` - Copy `count` bytes from `src` into the container.
288-
#[deprecated(
289-
note = "Use `.read_volatile_from` or the functions of the `ReadVolatile` trait instead"
290-
)]
291-
fn read_from<F>(&self, addr: A, src: &mut F, count: usize) -> Result<usize, Self::E>
292-
where
293-
F: Read;
294-
295-
/// Reads exactly `count` bytes from an object and writes them into the container at `addr`.
296-
///
297-
/// # Errors
298-
///
299-
/// Returns an error if `count` bytes couldn't have been copied from `src` to the container.
300-
/// Part of the data may have been copied nevertheless.
301-
///
302-
/// # Arguments
303-
/// * `addr` - Begin writing at this address.
304-
/// * `src` - Copy from `src` into the container.
305-
/// * `count` - Copy exactly `count` bytes from `src` into the container.
306-
#[deprecated(
307-
note = "Use `.read_exact_volatile_from` or the functions of the `ReadVolatile` trait instead"
308-
)]
309-
fn read_exact_from<F>(&self, addr: A, src: &mut F, count: usize) -> Result<(), Self::E>
310-
where
311-
F: Read;
312-
313-
/// Reads up to `count` bytes from the container at `addr` and writes them it into an object.
314-
///
315-
/// Returns the number of bytes written into the object.
316-
///
317-
/// # Arguments
318-
/// * `addr` - Begin reading from this address.
319-
/// * `dst` - Copy from the container to `dst`.
320-
/// * `count` - Copy `count` bytes from the container to `dst`.
321-
#[deprecated(
322-
note = "Use `.write_volatile_to` or the functions of the `WriteVolatile` trait instead"
323-
)]
324-
fn write_to<F>(&self, addr: A, dst: &mut F, count: usize) -> Result<usize, Self::E>
325-
where
326-
F: Write;
327-
328-
/// Reads exactly `count` bytes from the container at `addr` and writes them into an object.
329-
///
330-
/// # Errors
331-
///
332-
/// Returns an error if `count` bytes couldn't have been copied from the container to `dst`.
333-
/// Part of the data may have been copied nevertheless.
334-
///
335-
/// # Arguments
336-
/// * `addr` - Begin reading from this address.
337-
/// * `dst` - Copy from the container to `dst`.
338-
/// * `count` - Copy exactly `count` bytes from the container to `dst`.
339-
#[deprecated(
340-
note = "Use `.write_all_volatile_to` or the functions of the `WriteVolatile` trait instead"
341-
)]
342-
fn write_all_to<F>(&self, addr: A, dst: &mut F, count: usize) -> Result<(), Self::E>
343-
where
344-
F: Write;
345-
346279
/// Atomically store a value at the specified address.
347280
fn store<T: AtomicAccess>(&self, val: T, addr: A, order: Ordering) -> Result<(), Self::E>;
348281

@@ -481,34 +414,6 @@ pub(crate) mod tests {
481414
Ok(())
482415
}
483416

484-
fn read_from<F>(&self, _: usize, _: &mut F, _: usize) -> Result<usize, Self::E>
485-
where
486-
F: Read,
487-
{
488-
unimplemented!()
489-
}
490-
491-
fn read_exact_from<F>(&self, _: usize, _: &mut F, _: usize) -> Result<(), Self::E>
492-
where
493-
F: Read,
494-
{
495-
unimplemented!()
496-
}
497-
498-
fn write_to<F>(&self, _: usize, _: &mut F, _: usize) -> Result<usize, Self::E>
499-
where
500-
F: Write,
501-
{
502-
unimplemented!()
503-
}
504-
505-
fn write_all_to<F>(&self, _: usize, _: &mut F, _: usize) -> Result<(), Self::E>
506-
where
507-
F: Write,
508-
{
509-
unimplemented!()
510-
}
511-
512417
fn store<T: AtomicAccess>(
513418
&self,
514419
_val: T,

0 commit comments

Comments
 (0)