[−][src]Trait rubbl_core::io::OpenResultExt
This is an extension trait that makes it more convenient to handle errors when opening files that may be missing.
Various parts of Rubbl try to open files but don’t mind if the files are
missing. This is expressed using return types like Result<Option<File>>
:
if the value is Ok(None)
, that means that the file was not found, even
though the underlying I/O operation probably return an Err
type.
There are times when we want to use these APIs, but it actually is an
error if the file in question is missing. This trait provides a
require_found
method on the Result<Option<T>>
type that removes the
Option
layer of the type, converting Ok(None)
into an Err
containing
a NotFound
error.
Associated Types
type Reprocessed
The output type of the require_found
method.
Result<Option<T>>
becomes Result<T>
. Due to the way the trait is
specified, we have to use an associated type to express this fact.
Required methods
fn require_found(self) -> Self::Reprocessed
If self is Ok(None)
, convert it into an Err
with a NotFound
type.
Implementations on Foreign Types
impl<T, E> OpenResultExt for Result<Option<T>, E> where
E: From<Error>,
[src]
E: From<Error>,