Skip to content

Commit c828250

Browse files
Minor clean-ups of docs.
Trying to make the cargo-doc output look good. Also adds an Apache-2.0 NOTICE file.
1 parent 44a5736 commit c828250

File tree

12 files changed

+59
-43
lines changed

12 files changed

+59
-43
lines changed

LICENSE-MIT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Copyright (c) 2018-2023 Jonathan 'theJPster' Pallant and the Rust Embedded Community developers
1+
Copyright (c) 2018-2024 Jonathan 'theJPster' Pallant and the Rust Embedded Community developers
2+
Copyright (c) 2011-2018 Bill Greiman
23

34
Permission is hereby granted, free of charge, to any
45
person obtaining a copy of this software and associated

NOTICE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright Notices
2+
3+
This is a copyright notices file, as described by the Apache-2.0 license.
4+
5+
Copyright (c) 2018-2024 Jonathan 'theJPster' Pallant and the Rust Embedded Community developers
6+
Copyright (c) 2011-2018 Bill Greiman

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ let mut cont: VolumeManager<_, _, 6, 12, 4> = VolumeManager::new_with_limits(blo
5959
* Log over defmt or the common log interface (feature flags).
6060

6161
## No-std usage
62+
6263
This repository houses no examples for no-std usage, however you can check out the following examples:
63-
- [Pi Pico](https://github.com/rp-rs/rp-hal-boards/blob/main/boards/rp-pico/examples/pico_spi_sd_card.rs)
64-
- [STM32H7XX](https://github.com/stm32-rs/stm32h7xx-hal/blob/master/examples/sdmmc_fat.rs)
65-
- [atsamd(pygamer)](https://github.com/atsamd-rs/atsamd/blob/master/boards/pygamer/examples/sd_card.rs)
64+
65+
* [Pi Pico](https://github.com/rp-rs/rp-hal-boards/blob/main/boards/rp-pico/examples/pico_spi_sd_card.rs)
66+
* [STM32H7XX](https://github.com/stm32-rs/stm32h7xx-hal/blob/master/examples/sdmmc_fat.rs)
67+
* [atsamd(pygamer)](https://github.com/atsamd-rs/atsamd/blob/master/boards/pygamer/examples/sd_card.rs)
6668

6769
## Todo List (PRs welcome!)
6870

@@ -79,12 +81,14 @@ The changelog has moved to [CHANGELOG.md](/CHANGELOG.md)
7981
Licensed under either of
8082

8183
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
82-
http://www.apache.org/licenses/LICENSE-2.0)
84+
<http://www.apache.org/licenses/LICENSE-2.0>)
8385

84-
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
86+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
8587

8688
at your option.
8789

90+
Copyright notices are stored in the [NOTICE](./NOTICE) file.
91+
8892
## Contribution
8993

9094
Unless you explicitly state otherwise, any contribution intentionally

src/blockdevice.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
//! Block Device support
1+
//! Traits and types for working with Block Devices.
22
//!
33
//! Generic code for handling block devices, such as types for identifying
44
//! a particular block on a block device by its index.
55
6-
/// Represents a standard 512 byte block (also known as a sector). IBM PC
7-
/// formatted 5.25" and 3.5" floppy disks, SD/MMC cards up to 1 GiB in size
8-
/// and IDE/SATA Hard Drives up to about 2 TiB all have 512 byte blocks.
6+
/// A standard 512 byte block (also known as a sector).
7+
///
8+
/// IBM PC formatted 5.25" and 3.5" floppy disks, IDE/SATA Hard Drives up to
9+
/// about 2 TiB, and almost all SD/MMC cards have 512 byte blocks.
910
///
1011
/// This library does not support devices with a block size other than 512
1112
/// bytes.
@@ -15,15 +16,17 @@ pub struct Block {
1516
pub contents: [u8; Block::LEN],
1617
}
1718

18-
/// Represents the linear numeric address of a block (or sector). The first
19-
/// block on a disk gets `BlockIdx(0)` (which usually contains the Master Boot
20-
/// Record).
19+
/// The linear numeric address of a block (or sector).
20+
///
21+
/// The first block on a disk gets `BlockIdx(0)` (which usually contains the
22+
/// Master Boot Record).
2123
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
2224
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
2325
pub struct BlockIdx(pub u32);
2426

25-
/// Represents the a number of blocks (or sectors). Add this to a `BlockIdx`
26-
/// to get an actual address on disk.
27+
/// The a number of blocks (or sectors).
28+
///
29+
/// Add this to a `BlockIdx` to get an actual address on disk.
2730
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
2831
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
2932
pub struct BlockCount(pub u32);
@@ -34,7 +37,7 @@ pub struct BlockIter {
3437
current: BlockIdx,
3538
}
3639

37-
/// Represents a block device - a device which can read and write blocks (or
40+
/// A block device - a device which can read and write blocks (or
3841
/// sectors). Only supports devices which are <= 2 TiB in size.
3942
pub trait BlockDevice {
4043
/// The errors that the `BlockDevice` can return. Must be debug formattable.

src/fat/bpb.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ use crate::{
66
};
77
use byteorder::{ByteOrder, LittleEndian};
88

9-
/// Represents a Boot Parameter Block. This is the first sector of a FAT
10-
/// formatted partition, and it describes various properties of the FAT
11-
/// filesystem.
9+
/// A Boot Parameter Block.
10+
///
11+
/// This is the first sector of a FAT formatted partition, and it describes
12+
/// various properties of the FAT filesystem.
1213
pub struct Bpb<'a> {
1314
data: &'a [u8; 512],
1415
pub(crate) fat_type: FatType,

src/fat/ondiskdirentry.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
use crate::{fat::FatType, Attributes, BlockIdx, ClusterId, DirEntry, ShortFileName, Timestamp};
44
use byteorder::{ByteOrder, LittleEndian};
55

6-
/// Represents a 32-byte directory entry as stored on-disk in a directory file.
6+
/// A 32-byte directory entry as stored on-disk in a directory file.
7+
///
8+
/// This is the same for FAT16 and FAT32 (except FAT16 doesn't use
9+
/// first_cluster_hi).
710
pub struct OnDiskDirEntry<'a> {
811
data: &'a [u8],
912
}
@@ -38,8 +41,6 @@ impl<'a> core::fmt::Debug for OnDiskDirEntry<'a> {
3841
}
3942
}
4043

41-
/// Represents the 32 byte directory entry. This is the same for FAT16 and
42-
/// FAT32 (except FAT16 doesn't use first_cluster_hi).
4344
impl<'a> OnDiskDirEntry<'a> {
4445
pub(crate) const LEN: usize = 32;
4546
pub(crate) const LEN_U32: u32 = 32;

src/filesystem/directory.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use crate::{Error, RawVolume, VolumeManager};
77

88
use super::ToShortFileName;
99

10-
/// Represents a directory entry, which tells you about
11-
/// other files and directories.
10+
/// A directory entry, which tells you about other files and directories.
1211
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
1312
#[derive(Debug, PartialEq, Eq, Clone)]
1413
pub struct DirEntry {
@@ -30,7 +29,7 @@ pub struct DirEntry {
3029
pub entry_offset: u32,
3130
}
3231

33-
/// Represents an open directory on disk.
32+
/// A handle for an open directory on disk.
3433
///
3534
/// Do NOT drop this object! It doesn't hold a reference to the Volume Manager
3635
/// it was created from and if you drop it, the VolumeManager will think you
@@ -70,7 +69,7 @@ impl RawDirectory {
7069
}
7170
}
7271

73-
/// Represents an open directory on disk.
72+
/// A handle for an open directory on disk, which closes on drop.
7473
///
7574
/// In contrast to a `RawDirectory`, a `Directory` holds a mutable reference to
7675
/// its parent `VolumeManager`, which restricts which operations you can perform.

src/filesystem/files.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
Error, RawVolume, VolumeManager,
44
};
55

6-
/// Represents an open file on disk.
6+
/// A handle for an open file on disk.
77
///
88
/// Do NOT drop this object! It doesn't hold a reference to the Volume Manager
99
/// it was created from and cannot update the directory entry if you drop it.
@@ -37,7 +37,7 @@ impl RawFile {
3737
}
3838
}
3939

40-
/// Represents an open file on disk.
40+
/// A handle for an open file on disk, which closes on drop.
4141
///
4242
/// In contrast to a `RawFile`, a `File` holds a mutable reference to its
4343
/// parent `VolumeManager`, which restricts which operations you can perform.

src/filesystem/timestamp.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ pub trait TimeSource {
44
fn get_timestamp(&self) -> Timestamp;
55
}
66

7-
/// Represents an instant in time, in the local time zone. TODO: Consider
8-
/// replacing this with POSIX time as a `u32`, which would save two bytes at
9-
/// the expense of some maths.
7+
/// A Gregorian Calendar date/time, in the local time zone.
8+
///
9+
/// TODO: Consider replacing this with POSIX time as a `u32`, which would save
10+
/// two bytes at the expense of some maths.
1011
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
1112
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
1213
pub struct Timestamp {

src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! warn {
135135
//
136136
// ****************************************************************************
137137

138-
/// Represents all the ways the functions in this crate can fail.
138+
/// All the ways the functions in this crate can fail.
139139
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
140140
#[derive(Debug, Clone)]
141141
pub enum Error<E>
@@ -211,7 +211,7 @@ where
211211
}
212212
}
213213

214-
/// Represents a partition with a filesystem within it.
214+
/// A partition with a filesystem within it.
215215
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
216216
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
217217
pub struct RawVolume(SearchId);
@@ -236,7 +236,7 @@ impl RawVolume {
236236
}
237237
}
238238

239-
/// Represents an open volume on disk.
239+
/// An open volume on disk, which closes on drop.
240240
///
241241
/// In contrast to a `RawVolume`, a `Volume` holds a mutable reference to its
242242
/// parent `VolumeManager`, which restricts which operations you can perform.
@@ -354,8 +354,7 @@ pub enum VolumeType {
354354
Fat(FatVolume),
355355
}
356356

357-
/// A `VolumeIdx` is a number which identifies a volume (or partition) on a
358-
/// disk.
357+
/// A number which identifies a volume (or partition) on a disk.
359358
///
360359
/// `VolumeIdx(0)` is the first primary partition on an MBR partitioned disk.
361360
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]

src/sdcard/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! The SD/MMC Protocol
2-
//!
3-
//! Implements the SD/MMC protocol on some generic SPI interface.
1+
//! Implements the BlockDevice trait for an SD/MMC Protocol over SPI.
42
//!
53
//! This is currently optimised for readability and debugability, not
64
//! performance.
@@ -21,7 +19,7 @@ use crate::{debug, warn};
2119
// Types and Implementations
2220
// ****************************************************************************
2321

24-
/// Represents an SD Card on an SPI bus.
22+
/// Driver for an SD Card on an SPI bus.
2523
///
2624
/// Built from an [`SpiDevice`] implementation and a Chip Select pin.
2725
///
@@ -201,7 +199,7 @@ where
201199
}
202200
}
203201

204-
/// Represents an SD Card on an SPI bus.
202+
/// Inner details for the SD Card driver.
205203
///
206204
/// All the APIs required `&mut self`.
207205
struct SdCardInner<SPI, DELAYER>

src/volume_mgr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ use crate::{
1818
};
1919
use heapless::Vec;
2020

21-
/// A `VolumeManager` wraps a block device and gives access to the FAT-formatted
22-
/// volumes within it.
21+
/// Wraps a block device and gives access to the FAT-formatted volumes within
22+
/// it.
23+
///
24+
/// Tracks which files and directories are open, to prevent you from deleting
25+
/// a file or directory you currently have open.
2326
#[derive(Debug)]
2427
pub struct VolumeManager<
2528
D,

0 commit comments

Comments
 (0)