Skip to content

Commit 4c5c0c7

Browse files
committed
Fix typo and inconsistency in the doc
1 parent 0b7d158 commit 4c5c0c7

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Library Usage
6565
-------------
6666
6767
Reading all the partitions of a disk:
68+
6869
```rust
6970
let mut f = std::fs::File::open("tests/fixtures/disk1.img")
7071
.expect("could not open disk");
@@ -83,7 +84,9 @@ for (i, p) in gpt.iter() {
8384
}
8485
}
8586
```
87+
8688
Creating new partitions:
89+
8790
```rust
8891
let mut f = std::fs::File::open("tests/fixtures/disk1.img")
8992
.expect("could not open disk");
@@ -107,7 +110,9 @@ gpt[free_partition_number] = gptman::GPTPartitionEntry {
107110
partition_name: "A Robot Named Fight!".into(),
108111
};
109112
```
113+
110114
Creating a new partition table with one entry that fills the entire disk:
115+
111116
```rust
112117
let ss = 512;
113118
let data = vec![0; 100 * ss as usize];

src/lib.rs

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! A library that allows managing GUID partition tables.
22
//!
33
//! # Examples
4+
//!
45
//! Reading all the partitions of a disk:
6+
//!
57
//! ```
68
//! let mut f = std::fs::File::open("tests/fixtures/disk1.img")
79
//! .expect("could not open disk");
@@ -20,7 +22,9 @@
2022
//! }
2123
//! }
2224
//! ```
25+
//!
2326
//! Creating new partitions:
27+
//!
2428
//! ```
2529
//! let mut f = std::fs::File::open("tests/fixtures/disk1.img")
2630
//! .expect("could not open disk");
@@ -44,7 +48,9 @@
4448
//! partition_name: "A Robot Named Fight!".into(),
4549
//! };
4650
//! ```
51+
//!
4752
//! Creating a new partition table with one entry that fills the entire disk:
53+
//!
4854
//! ```
4955
//! let ss = 512;
5056
//! let data = vec![0; 100 * ss as usize];
@@ -183,7 +189,7 @@ pub struct GPTHeader {
183189
pub disk_guid: [u8; 16],
184190
/// Location (in sectors) of the partition entries array.
185191
///
186-
/// This is always `2` if the header is a primary header and not the backup header.
192+
/// This is always `2` if the header is a primary header and not a backup header.
187193
pub partition_entry_lba: u64,
188194
/// Number of partition entries in the array.
189195
pub number_of_partition_entries: u32,
@@ -443,6 +449,7 @@ impl Serialize for PartitionName {
443449
/// A GPT partition's entry in the partition array.
444450
///
445451
/// # Examples
452+
///
446453
/// Basic usage:
447454
/// ```
448455
/// let ss = 512;
@@ -481,6 +488,7 @@ pub struct GPTPartitionEntry {
481488
/// The partition name.
482489
///
483490
/// # Examples
491+
///
484492
/// Basic usage:
485493
/// ```
486494
/// let name: gptman::PartitionName = "A Robot Named Fight!".into();
@@ -494,6 +502,7 @@ impl GPTPartitionEntry {
494502
/// Creates an empty partition entry
495503
///
496504
/// # Examples
505+
///
497506
/// Basic usage:
498507
/// ```
499508
/// let ss = 512;
@@ -540,9 +549,11 @@ impl GPTPartitionEntry {
540549
/// long at minimum.
541550
///
542551
/// # Errors
552+
///
543553
/// This function will return an error if the `ending_lba` is lesser than the `starting_lba`.
544554
///
545-
/// # Examples:
555+
/// # Examples
556+
///
546557
/// Basic usage:
547558
/// ```
548559
/// let ss = 512;
@@ -574,10 +585,11 @@ impl GPTPartitionEntry {
574585
}
575586
}
576587

577-
/// A type representing a GUID partition table including its partition, the sector size of the disk
578-
/// and the alignment of the partitions to the sectors.
588+
/// A type representing a GUID partition table including its partitions, the sector size of the
589+
/// disk and the alignment of the partitions to the sectors.
590+
///
591+
/// # Examples
579592
///
580-
/// # Examples:
581593
/// Read an existing GPT on a reader and list its partitions:
582594
/// ```
583595
/// let mut f = std::fs::File::open("tests/fixtures/disk1.img")
@@ -614,14 +626,16 @@ pub struct GPT {
614626
/// so they return only values aligned to the alignment.
615627
///
616628
/// # Panics
629+
///
617630
/// The value must be greater than 0, otherwise you will encounter divisions by zero.
618631
pub align: u64,
619632
}
620633

621634
impl GPT {
622635
/// Make a new GPT based on a reader. (This operation does not write anything to disk!)
623636
///
624-
/// # Examples:
637+
/// # Examples
638+
///
625639
/// Basic usage:
626640
/// ```
627641
/// let ss = 512;
@@ -715,7 +729,8 @@ impl GPT {
715729
/// size of 512 but if it fails it will automatically try to read the GPT using a sector size
716730
/// of 4096.
717731
///
718-
/// # Examples:
732+
/// # Examples
733+
///
719734
/// Basic usage:
720735
/// ```
721736
/// let mut f_512 = std::fs::File::open("tests/fixtures/disk1.img")
@@ -881,7 +896,8 @@ impl GPT {
881896
/// spot; and on the right: the size (in sectors) of the free spot.
882897
/// This function will automatically align with the alignment defined in the `GPT`.
883898
///
884-
/// # Examples:
899+
/// # Examples
900+
///
885901
/// Basic usage:
886902
/// ```
887903
/// let ss = 512;
@@ -933,7 +949,8 @@ impl GPT {
933949
/// given in parameter.
934950
/// This function will automatically align with the alignment defined in the `GPT`.
935951
///
936-
/// # Examples:
952+
/// # Examples
953+
///
937954
/// Basic usage:
938955
/// ```
939956
/// let ss = 512;
@@ -968,7 +985,8 @@ impl GPT {
968985
/// given in parameter.
969986
/// This function will automatically align with the alignment defined in the `GPT`.
970987
///
971-
/// # Examples:
988+
/// # Examples
989+
///
972990
/// Basic usage:
973991
/// ```
974992
/// let ss = 512;
@@ -1004,7 +1022,8 @@ impl GPT {
10041022
/// partition of the size given in parameter.
10051023
/// This function will automatically align with the alignment defined in the `GPT`.
10061024
///
1007-
/// # Examples:
1025+
/// # Examples
1026+
///
10081027
/// Basic usage:
10091028
/// ```
10101029
/// let ss = 512;
@@ -1043,7 +1062,8 @@ impl GPT {
10431062
/// Get the maximum size (in sectors) of a partition you could create in the GPT.
10441063
/// This function will automatically align with the alignment defined in the `GPT`.
10451064
///
1046-
/// # Examples:
1065+
/// # Examples
1066+
///
10471067
/// Basic usage:
10481068
/// ```
10491069
/// let ss = 512;
@@ -1086,7 +1106,8 @@ impl GPT {
10861106
/// `gpt[i] = gptman::GPTPartitionEntry::empty();`
10871107
///
10881108
/// # Errors
1089-
/// This function will return an error if index is lesser or equal to 0 or greater than the
1109+
///
1110+
/// This function will return an error if `i` is lesser or equal to `0` or greater than the
10901111
/// number of partition entries (which can be obtained in the header).
10911112
pub fn remove(&mut self, i: u32) -> Result<()> {
10921113
if i == 0 || i > self.header.number_of_partition_entries {
@@ -1101,6 +1122,7 @@ impl GPT {
11011122
/// Remove a partiton entry in the array that resides at a given sector.
11021123
///
11031124
/// # Errors
1125+
///
11041126
/// It is an error to provide a sector which does not belong to a partition.
11051127
pub fn remove_at_sector(&mut self, sector: u64) -> Result<()> {
11061128
self.remove(

0 commit comments

Comments
 (0)