Skip to content

Commit d1344ea

Browse files
jonathanpallanteldruin
authored andcommitted
Rename card_size_bytes to num_bytes.
Matches the num_blocks command in the BlockDevice API.
1 parent afdb7fb commit d1344ea

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You will need something that implements the `BlockDevice` trait, which can read
1313
```rust
1414
// Build an SD Card interface out of an SPI device
1515
let sdcard = embedded_sdmmc::SdCard::new(sdmmc_spi, sdmmc_cs);
16-
write!(uart, "Card size is {} bytes", sdcard.card_size_bytes()?)?;
16+
write!(uart, "Card size is {} bytes", sdcard.num_bytes()?)?;
1717
// Now let's look for volumes (also known as partitions) on our block device.
1818
let mut cont = embedded_sdmmc::VolumeManager::new(sdcard, time_source);
1919
// Try and access Volume 0 (i.e. the first partition)

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
//! # let mut sdmmc_cs = DummyCsPin;
4242
//! # let time_source = DummyTimeSource;
4343
//! let sdcard = embedded_sdmmc::SdCard::new(sdmmc_spi, sdmmc_cs);
44-
//! println!("Card size {} bytes", sdcard.card_size_bytes()?);
44+
//! println!("Card size {} bytes", sdcard.num_bytes()?);
4545
//! let mut volume_mgr = VolumeManager::new(sdcard, time_source);
46-
//! println!("Card size is still {} bytes", volume_mgr.device().card_size_bytes()?);
46+
//! println!("Card size is still {} bytes", volume_mgr.device().num_bytes()?);
4747
//! let mut volume0 = volume_mgr.get_volume(embedded_sdmmc::VolumeIdx(0))?;
4848
//! println!("Volume 0: {:?}", volume0);
4949
//! let root_dir = volume_mgr.open_root_dir(&volume0)?;

src/sdcard/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ where
8989
}
9090

9191
/// Return the usable size of this SD card in bytes.
92-
pub fn card_size_bytes(&self) -> Result<u64, Error> {
92+
pub fn num_bytes(&self) -> Result<u64, Error> {
9393
let mut inner = self.inner.borrow_mut();
9494
inner.check_init()?;
95-
inner.card_size_bytes()
95+
inner.num_bytes()
9696
}
9797

9898
/// Can this card erase single blocks?
@@ -166,7 +166,7 @@ where
166166
fn num_blocks(&self) -> Result<BlockCount, Self::Error> {
167167
let mut inner = self.inner.borrow_mut();
168168
inner.check_init()?;
169-
inner.card_size_blocks()
169+
inner.num_blocks()
170170
}
171171
}
172172

@@ -251,7 +251,7 @@ where
251251
}
252252

253253
/// Determine how many blocks this device can hold.
254-
fn card_size_blocks(&mut self) -> Result<BlockCount, Error> {
254+
fn num_blocks(&mut self) -> Result<BlockCount, Error> {
255255
let num_blocks = self.with_chip_select(|s| {
256256
let csd = s.read_csd()?;
257257
debug!("CSD: {:?}", csd);
@@ -264,7 +264,7 @@ where
264264
}
265265

266266
/// Return the usable size of this SD card in bytes.
267-
fn card_size_bytes(&mut self) -> Result<u64, Error> {
267+
fn num_bytes(&mut self) -> Result<u64, Error> {
268268
self.with_chip_select(|s| {
269269
let csd = s.read_csd()?;
270270
debug!("CSD: {:?}", csd);

0 commit comments

Comments
 (0)