Struct erupt::utils::VulkanResult
source · Expand description
Idiomatic wrapper around a Vulkan Result.
In order to use this type with the ?
operator, call the
.result()
method first.
Using the ?
operator directly on this type is blocked on
rust-lang/rust#84277.
Fields
raw: Result
The raw result from Vulkan.
value: Option<T>
The value this wrapper type may be holding.
Implementations
sourceimpl<T> VulkanResult<T>
impl<T> VulkanResult<T>
sourcepub fn new(raw: Result, value: T) -> VulkanResult<T>
pub fn new(raw: Result, value: T) -> VulkanResult<T>
Construct a new VulkanResult
from raw
and value
.
This will not populate self.value
if the raw result is negative (Error).
sourcepub fn unwrap(self) -> T
pub fn unwrap(self) -> T
Returns the contained value, consuming self
.
Panics with the name of self.raw
if self.value
is None
.
sourcepub fn expect(self, msg: impl Display) -> T
pub fn expect(self, msg: impl Display) -> T
Returns the contained value, consuming self
.
Panics with msg
and the name of self.raw
if self.value
is None
.
sourcepub fn as_ref(&self) -> VulkanResult<&T>
pub fn as_ref(&self) -> VulkanResult<&T>
Converts from &VulkanResult<T>
to VulkanResult<&T>
.
Clones self.raw
.
sourcepub fn as_mut(&mut self) -> VulkanResult<&mut T>
pub fn as_mut(&mut self) -> VulkanResult<&mut T>
Converts from &mut VulkanResult<T>
to VulkanResult<&mut T>
.
Clones self.raw
.
sourcepub fn new_ok(value: T) -> VulkanResult<T>
pub fn new_ok(value: T) -> VulkanResult<T>
Constructs a new VulkanResult
from value
.
This will always set self.raw
to vk::Result::SUCCESS
.
sourcepub fn new_err(raw: Result) -> VulkanResult<T>
pub fn new_err(raw: Result) -> VulkanResult<T>
Constructs a new VulkanResult
from raw
.
This will always set self.value
to None
.
sourcepub fn result(self) -> Result<T, Result>
pub fn result(self) -> Result<T, Result>
Maps Some(v)
of self.value
to Ok(v)
and None
of self.value
to Err(self.raw)
.
sourcepub fn map_err<F, O: FnOnce(Result) -> F>(self, op: O) -> Result<T, F>
pub fn map_err<F, O: FnOnce(Result) -> F>(self, op: O) -> Result<T, F>
Maps Some(v)
of self.value
to Ok(v)
and None
of self.value
to Err(op(self.raw))
.
sourcepub fn raw_is_err(&self) -> bool
pub fn raw_is_err(&self) -> bool
Returns true
if self.raw
is negative.
Trait Implementations
sourceimpl<T: Clone> Clone for VulkanResult<T>
impl<T: Clone> Clone for VulkanResult<T>
sourcefn clone(&self) -> VulkanResult<T>
fn clone(&self) -> VulkanResult<T>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more