From c4a1bc70ec226e1198ababdffa92eb917c86fa41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Harabie=C5=84?= Date: Wed, 20 Jun 2018 17:38:04 +0200 Subject: [PATCH] Rename methods: bytes -> as_bytes --- src/dir.rs | 2 +- src/dir_entry.rs | 10 +++++----- src/fs.rs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dir.rs b/src/dir.rs index 7722a31..251560a 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -240,7 +240,7 @@ impl <'a, T: ReadWriteSeek + 'a> Dir<'a, T> { // check if directory contains no files for r in self.iter() { let e = r?; - let name = e.short_file_name_bytes(); + let name = e.short_file_name_as_bytes(); // ignore special entries "." and ".." if name != ".".as_bytes() && name != "..".as_bytes() { return Ok(false); diff --git a/src/dir_entry.rs b/src/dir_entry.rs index 7e92a2f..63b5aff 100644 --- a/src/dir_entry.rs +++ b/src/dir_entry.rs @@ -71,21 +71,21 @@ impl ShortName { } } - fn bytes(&self) -> &[u8] { + fn as_bytes(&self) -> &[u8] { &self.name[..self.len as usize] } #[cfg(feature = "alloc")] fn to_string(&self) -> String { // Strip non-ascii characters from short name - let char_iter = self.bytes().iter().cloned().map(decode_oem_char_lossy); + let char_iter = self.as_bytes().iter().cloned().map(decode_oem_char_lossy); // Build string from character iterator String::from_iter(char_iter) } fn eq_ignore_ascii_case(&self, name: &str) -> bool { // Strip non-ascii characters from short name - let char_iter = self.bytes().iter().cloned().map(decode_oem_char_lossy).map(|c| c.to_ascii_uppercase()); + let char_iter = self.as_bytes().iter().cloned().map(decode_oem_char_lossy).map(|c| c.to_ascii_uppercase()); // Build string from character iterator char_iter.eq(name.chars().map(|c| c.to_ascii_uppercase())) } @@ -645,8 +645,8 @@ impl <'a, T: ReadWriteSeek> DirEntry<'a, T> { /// Returns short file name as byte array slice. /// /// Characters are encoded in the OEM codepage. - pub fn short_file_name_bytes(&self) -> &[u8] { - self.short_name.bytes() + pub fn short_file_name_as_bytes(&self) -> &[u8] { + self.short_name.as_bytes() } /// Returns long file name or if it doesn't exist fallbacks to short file name. diff --git a/src/fs.rs b/src/fs.rs index 64c82d3..0ad8c2e 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -442,7 +442,7 @@ impl FileSystem { #[cfg(feature = "alloc")] pub fn volume_label(&self) -> String { // Strip non-ascii characters from volume label - let char_iter = self.volume_label_bytes().iter().cloned().map(decode_oem_char_lossy); + let char_iter = self.volume_label_as_bytes().iter().cloned().map(decode_oem_char_lossy); // Build string from character iterator String::from_iter(char_iter) } @@ -452,7 +452,7 @@ impl FileSystem { /// Label is encoded in the OEM codepage. /// Note: File with `VOLUME_ID` attribute in root directory is ignored by this library. /// Only label from BPB is used. - pub fn volume_label_bytes(&self) -> &[u8] { + pub fn volume_label_as_bytes(&self) -> &[u8] { let full_label_slice = &self.bpb.volume_label; let len = full_label_slice.iter().rposition(|b| *b != 0x20).map(|p| p + 1).unwrap_or(0); &full_label_slice[..len]