Skip to content

Commit 2c12656

Browse files
committed
FileHandle::into_type does no longer return a result
1 parent ff963b2 commit 2c12656

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
`EqStrUntilNul` to find out limitations and further information.
1818
- the `File` trait now knows the methods `is_regular_file()` and `is_directory`.
1919
Developers profit from this on the struct `FileHandle`, for example.
20+
- **Breaking**`: FileHandle::into_type()` does no longer return a Result but a direct type
2021

2122
### Changed
2223

src/proto/media/file/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,20 @@ impl FileHandle {
252252

253253
/// Converts `File` into a more specific subtype based on if it is a
254254
/// directory or not. It does this via a call to `get_position`.
255-
pub fn into_type(self) -> Result<FileType> {
255+
pub fn into_type(self) -> FileType {
256256
use FileType::*;
257257

258258
if self.is_regular_file() {
259-
unsafe { Ok(Regular(RegularFile::new(self))) }
259+
unsafe { Regular(RegularFile::new(self)) }
260260
} else {
261-
unsafe { Ok(Dir(Directory::new(self))) }
261+
unsafe { Dir(Directory::new(self)) }
262262
}
263263
}
264264

265265
/// If the handle represents a directory, convert it into a
266266
/// [`Directory`]. Otherwise returns `None`.
267267
pub fn into_directory(self) -> Option<Directory> {
268-
if let Ok(FileType::Dir(dir)) = self.into_type() {
268+
if let FileType::Dir(dir) = self.into_type() {
269269
Some(dir)
270270
} else {
271271
None
@@ -275,7 +275,7 @@ impl FileHandle {
275275
/// If the handle represents a regular file, convert it into a
276276
/// [`RegularFile`]. Otherwise returns `None`.
277277
pub fn into_regular_file(self) -> Option<RegularFile> {
278-
if let Ok(FileType::Regular(regular)) = self.into_type() {
278+
if let FileType::Regular(regular) = self.into_type() {
279279
Some(regular)
280280
} else {
281281
None

uefi-test-runner/src/proto/media/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn test_simple_file_system_protocol(image: Handle, bt: &BootServices) {
7979
)
8080
.unwrap();
8181
assert!(created_file.is_regular_file());
82-
let created_file = match created_file.into_type().unwrap() {
82+
let created_file = match created_file.into_type() {
8383
FileType::Regular(file) => file,
8484
_ => panic!("unsupported value"),
8585
};

0 commit comments

Comments
 (0)