Skip to content

Commit 788019f

Browse files
jmcconnell26andreeaflorescu
authored andcommitted
ISSUE-67 - Enable doc_markdown clippy
* Enable doc_markdown clippy * Make clippy recommended changes to existing docs Fixes: #67 Signed-off-by: joshmc <[email protected]>
1 parent fecbb28 commit 788019f

File tree

5 files changed

+37
-33
lines changed

5 files changed

+37
-33
lines changed

src/address.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! Traits to represent an address within an address space.
1212
//!
1313
//! Two traits are defined to represent an address within an address space:
14-
//! - [AddressValue](trait.AddressValue.html): stores the raw value of an address. Typically `u32`,
15-
//! `u64` or `usize` is used to store the raw value. But pointers, such as `*u8`, can't be used
14+
//! - [`AddressValue`](trait.AddressValue.html): stores the raw value of an address. Typically
15+
//! `u32`,`u64` or `usize` is used to store the raw value. But pointers, such as `*u8`, can't be used
1616
//! because they don't implement the [`Add`](https://doc.rust-lang.org/std/ops/trait.Add.html) and
1717
//! [`Sub`](https://doc.rust-lang.org/std/ops/trait.Sub.html) traits.
1818
//! - [Address](trait.Address.html): encapsulates an [`AddressValue`](trait.AddressValue.html)
@@ -51,15 +51,15 @@ pub trait AddressValue {
5151

5252
/// Trait to represent an address within an address space.
5353
///
54-
/// To simplify the design and implementation, assume the same raw data type (AddressValue::V)
55-
/// could be used to store address, size and offset for the address space. Thus the Address trait
54+
/// To simplify the design and implementation, assume the same raw data type `(AddressValue::V)`
55+
/// could be used to store address, size and offset for the address space. Thus the `Address` trait
5656
/// could be used to manage address, size and offset. On the other hand, type aliases may be
5757
/// defined to improve code readability.
5858
///
59-
/// One design rule is applied to the Address trait, namely that operators (+, -, &, | etc) are not
60-
/// supported and it forces clients to explicitly invoke corresponding methods. But there are
59+
/// One design rule is applied to the `Address` trait, namely that operators (+, -, &, | etc) are
60+
/// not supported and it forces clients to explicitly invoke corresponding methods. But there are
6161
/// always exceptions:
62-
/// Address (BitAnd|BitOr) AddressValue are supported.
62+
/// `Address` (BitAnd|BitOr) `AddressValue` are supported.
6363
pub trait Address:
6464
AddressValue
6565
+ Sized

src/bytes.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//
99
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
1010

11-
//! Define the ByteValued trait to mark that it is safe to instantiate the struct with random data.
11+
//! Define the `ByteValued` trait to mark that it is safe to instantiate the struct with random
12+
//! data.
1213
1314
use crate::VolatileSlice;
1415
use std::io::{Read, Write};
@@ -102,12 +103,12 @@ pub unsafe trait ByteValued: Copy + Default + Send + Sync {
102103
unsafe { from_raw_parts_mut(self as *mut Self as *mut u8, size_of::<Self>()) }
103104
}
104105

105-
/// Converts a mutable reference to `self` into a VolatileSlice. This is
106+
/// Converts a mutable reference to `self` into a `VolatileSlice`. This is
106107
/// useful because `VolatileSlice` provides a `Bytes<usize>` implementation.
107108
///
108109
/// # Safety
109110
///
110-
/// Unlike most VolatileMemory implementation, this method requires an exclusive
111+
/// Unlike most `VolatileMemory` implementation, this method requires an exclusive
111112
/// reference to `self`; this trivially fulfills `VolatileSlice::new`'s requirement
112113
/// that all accesses to `self` use volatile accesses (because there can
113114
/// be no other accesses).

src/guest_memory.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717
//! a hypervisor).
1818
//!
1919
//! Traits and Structs
20-
//! - [GuestAddress](struct.GuestAddress.html): represents a guest physical address (GPA).
21-
//! - [MemoryRegionAddress](struct.MemoryRegionAddress.html): represents an offset inside a region.
22-
//! - [GuestMemoryRegion](trait.GuestMemoryRegion.html): represent a continuous region of guest's
20+
//! - [`GuestAddress`](struct.GuestAddress.html): represents a guest physical address (GPA).
21+
//! - [`MemoryRegionAddress`](struct.MemoryRegionAddress.html): represents an offset inside a
22+
//! region.
23+
//! - [`GuestMemoryRegion`](trait.GuestMemoryRegion.html): represent a continuous region of guest's
2324
//! physical memory.
24-
//! - [GuestMemory](trait.GuestMemory.html): represent a collection of GuestMemoryRegion objects.
25-
//! The main responsibilities of the GuestMemory trait are:
25+
//! - [`GuestMemory`](trait.GuestMemory.html): represent a collection of `GuestMemoryRegion`
26+
//! objects.
27+
//! The main responsibilities of the `GuestMemory` trait are:
2628
//! - hide the detail of accessing guest's physical address.
27-
//! - map a request address to a GuestMemoryRegion object and relay the request to it.
28-
//! - handle cases where an access request spanning two or more GuestMemoryRegion objects.
29+
//! - map a request address to a `GuestMemoryRegion` object and relay the request to it.
30+
//! - handle cases where an access request spanning two or more `GuestMemoryRegion` objects.
2931
//!
30-
//! Whenever a collection of GuestMemoryRegion objects is mutable,
31-
//! [GuestAddressSpace](trait.GuestAddressSpace.html) should be implemented
32-
//! for clients to obtain a [GuestMemory] reference or smart pointer.
32+
//! Whenever a collection of `GuestMemoryRegion` objects is mutable,
33+
//! [`GuestAddressSpace`](trait.GuestAddressSpace.html) should be implemented
34+
//! for clients to obtain a [`GuestMemory`] reference or smart pointer.
3335
3436
use std::convert::From;
3537
use std::fmt::{self, Display};
@@ -122,7 +124,7 @@ impl_address_ops!(GuestAddress, u64);
122124
pub struct MemoryRegionAddress(pub u64);
123125
impl_address_ops!(MemoryRegionAddress, u64);
124126

125-
/// Type of the raw value stored in a GuestAddress object.
127+
/// Type of the raw value stored in a `GuestAddress` object.
126128
pub type GuestUsize = <GuestAddress as AddressValue>::V;
127129

128130
/// Represents the start point within a `File` that backs a `GuestMemoryRegion`.
@@ -287,15 +289,15 @@ pub trait GuestMemoryRegion: Bytes<MemoryRegionAddress, E = Error> {
287289
}
288290
}
289291

290-
/// GuestAddressSpace provides a way to retrieve a GuestMemory object.
292+
/// `GuestAddressSpace` provides a way to retrieve a `GuestMemory` object.
291293
/// The vm-memory crate already provides trivial implementation for
292-
/// references to GuestMemory or reference-counted GuestMemory objects,
294+
/// references to `GuestMemory` or reference-counted `GuestMemory` objects,
293295
/// but the trait can also be implemented by any other struct in order
294296
/// to provide temporary access to a snapshot of the memory map.
295297
///
296298
/// In order to support generic mutable memory maps, devices (or other things
297-
/// that access memory) should store the memory as a GuestAddressSpace<M>.
298-
/// This example shows that references can also be used as the GuestAddressSpace
299+
/// that access memory) should store the memory as a `GuestAddressSpace<M>`.
300+
/// This example shows that references can also be used as the `GuestAddressSpace`
299301
/// implementation, providing a zero-cost abstraction whenever immutable memory
300302
/// maps are sufficient.
301303
///
@@ -391,15 +393,15 @@ impl<M: GuestMemory> GuestAddressSpace for Arc<M> {
391393
}
392394
}
393395

394-
/// GuestMemory represents a container for an *immutable* collection of
395-
/// GuestMemoryRegion objects. GuestMemory provides the `Bytes<GuestAddress>`
396+
/// `GuestMemory` represents a container for an *immutable* collection of
397+
/// `GuestMemoryRegion` objects. `GuestMemory` provides the `Bytes<GuestAddress>`
396398
/// trait to hide the details of accessing guest memory by physical address.
397-
/// Interior mutability is not allowed for implementations of GuestMemory so
399+
/// Interior mutability is not allowed for implementations of `GuestMemory` so
398400
/// that they always provide a consistent view of the memory map.
399401
///
400-
/// The task of the GuestMemory trait are:
401-
/// - map a request address to a GuestMemoryRegion object and relay the request to it.
402-
/// - handle cases where an access request spanning two or more GuestMemoryRegion objects.
402+
/// The task of the `GuestMemory` trait are:
403+
/// - map a request address to a `GuestMemoryRegion` object and relay the request to it.
404+
/// - handle cases where an access request spanning two or more `GuestMemoryRegion` objects.
403405
pub trait GuestMemory {
404406
/// Type of objects hosted by the address space.
405407
type R: GuestMemoryRegion;

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//! components, such as boot loader, virtual device drivers, virtio backend drivers and vhost
1717
//! drivers etc, could be shared and reused by multiple hypervisors.
1818
19+
#![deny(clippy::doc_markdown)]
1920
#![deny(missing_docs)]
2021

2122
#[macro_use]

src/volatile_memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl Bytes<usize> for VolatileSlice<'_> {
518518
type E = Error;
519519

520520
/// # Examples
521-
/// * Write a slice of size 5 at offset 1020 of a 1024-byte VolatileSlice.
521+
/// * Write a slice of size 5 at offset 1020 of a 1024-byte `VolatileSlice`.
522522
///
523523
/// ```
524524
/// # use vm_memory::{Bytes, VolatileMemory};
@@ -542,7 +542,7 @@ impl Bytes<usize> for VolatileSlice<'_> {
542542
}
543543

544544
/// # Examples
545-
/// * Read a slice of size 16 at offset 1010 of a 1024-byte VolatileSlice.
545+
/// * Read a slice of size 16 at offset 1010 of a 1024-byte `VolatileSlice`.
546546
///
547547
/// ```
548548
/// # use vm_memory::{Bytes, VolatileMemory};

0 commit comments

Comments
 (0)