diff --git a/src/address.rs b/src/address.rs index 25d3d911..c8f3e4e9 100644 --- a/src/address.rs +++ b/src/address.rs @@ -11,17 +11,17 @@ //! Traits to represent an address within an address space. //! //! Two traits are defined to present an address within an address space: -//! - [AddressValue](trait.AddressValue.html): stores the raw value of an address. Typically u32, +//! - [GuestUsize](trait.GuestUsize.html): stores the raw value of an address. Typically u32, //! u64 or usize is used to store the raw value. But pointers, such as *u8, can't be used because //! it doesn't implement the Add and Sub traits. -//! - [Address](trait.Address.html): encapsulates an AddressValue object and defines methods to +//! - [Address](trait.Address.html): encapsulates an GuestUsize object and defines methods to //! access and manipulate it. use std::cmp::{Eq, Ord, PartialEq, PartialOrd}; use std::ops::{Add, BitAnd, BitOr, Sub}; /// Simple helper trait used to store a raw address value. -pub trait AddressValue { +pub trait GuestUsize { /// Type of the address raw value. type V: Copy + PartialEq @@ -36,7 +36,7 @@ pub trait AddressValue { /// Trait to represent an address within an address space. /// -/// To simplify the design and implementation, assume the same raw data type (AddressValue::V) +/// To simplify the design and implementation, assume the same raw data type (GuestUsize::V) /// could be used to store address, size and offset for the address space. Thus the Address trait /// could be used to manage address, size and offset. On the other hand, type aliases may be /// defined to improve code readability. @@ -44,9 +44,9 @@ pub trait AddressValue { /// One design rule is applied to the Address trait that operators (+, -, &, | etc) are not /// supported and it forces clients to explicitly invoke corresponding methods. But there are /// always exceptions: -/// Address (BitAnd|BitOr) AddressValue are supported. +/// Address (BitAnd|BitOr) GuestUsize are supported. pub trait Address: - AddressValue + GuestUsize + Sized + Default + Copy @@ -54,8 +54,8 @@ pub trait Address: + PartialEq + Ord + PartialOrd - + BitAnd<::V, Output = Self> - + BitOr<::V, Output = Self> + + BitAnd<::V, Output = Self> + + BitOr<::V, Output = Self> { /// Create an address from a raw address value. fn new(addr: Self::V) -> Self; @@ -101,7 +101,7 @@ pub trait Address: macro_rules! impl_address_ops { ($T:ident, $V:ty) => { - impl AddressValue for $T { + impl GuestUsize for $T { type V = $V; } diff --git a/src/guest_memory.rs b/src/guest_memory.rs index dc5c11b3..176a33f1 100644 --- a/src/guest_memory.rs +++ b/src/guest_memory.rs @@ -32,7 +32,7 @@ use std::fmt::{self, Display}; use std::io::{self, Read, Write}; use std::ops::{BitAnd, BitOr}; -use address::{Address, AddressValue}; +use address::{Address, GuestUsize}; use bytes::Bytes; use volatile_memory; @@ -114,10 +114,10 @@ pub struct MemoryRegionAddress(pub u64); impl_address_ops!(MemoryRegionAddress, u64); /// Type of the raw value stored in a GuestAddress object. -pub type GuestAddressValue = ::V; +pub type GuestAddressValue = ::V; /// Type to encode offset in the guest physical address space. -pub type GuestAddressOffset = ::V; +pub type GuestAddressOffset = ::V; /// Represents a continuous region of guest physical memory. #[allow(clippy::len_without_is_empty)] diff --git a/src/lib.rs b/src/lib.rs index 125baed5..7491add1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ extern crate matches; #[macro_use] pub mod address; -pub use address::{Address, AddressValue}; +pub use address::{Address, GuestUsize}; pub mod bytes; pub use bytes::{ByteValued, Bytes};