Struct erupt::utils::VulkanResult[][src]

#[must_use = "this `VulkanResult` may be an error, which should be handled"]pub struct VulkanResult<T> {
    pub raw: Result,
    pub value: Option<T>,
}

Idiomatic wrapper around a Vulkan Result

Fields

raw: Result

The raw result from Vulkan

value: Option<T>

The value this wrapper type may be holding

Implementations

impl<T> VulkanResult<T>[src]

pub fn new(raw: Result, value: T) -> VulkanResult<T>[src]

Construct a new VulkanResult from raw and value

This will not populate self.value if the raw result is negative (Error)

pub fn unwrap(self) -> T[src]

Returns the contained value, consuming self

Panics with the name of self.raw if self.value is None

pub fn expect(self, msg: impl Display) -> T[src]

Returns the contained value, consuming self

Panics with msg and the name of self.raw if self.value is None

pub fn as_ref(&self) -> VulkanResult<&T>[src]

Converts from &VulkanResult<T> to VulkanResult<&T>

Clones self.raw

pub fn as_mut(&mut self) -> VulkanResult<&mut T>[src]

Converts from &mut VulkanResult<T> to VulkanResult<&mut T>

Clones self.raw

pub fn new_ok(value: T) -> VulkanResult<T>[src]

Constructs a new VulkanResult from value

This will always set self.raw to vk::Result::SUCCESS

pub fn new_err(raw: Result) -> VulkanResult<T>[src]

Constructs a new VulkanResult from raw

This will always set self.value to None

pub fn ok(self) -> Option<T>[src]

Returns self.value, consuming self and dropping self.raw

pub fn result(self) -> Result<T, Result>[src]

Maps Some(v) of self.value to Ok(v) and None of self.value to Err(self.raw)

pub fn map_err<F, O: FnOnce(Result) -> F>(self, op: O) -> Result<T, F>[src]

Maps Some(v) of self.value to Ok(v) and None of self.value to Err(op(self.raw))

pub fn is_ok(&self) -> bool[src]

Returns true if self.value is Some

pub fn raw_is_ok(&self) -> bool[src]

Returns true if self.raw is positive

pub fn is_err(&self) -> bool[src]

Returns true if self.value is None

pub fn raw_is_err(&self) -> bool[src]

Returns true if self.raw is negative

Trait Implementations

impl<T: Clone> Clone for VulkanResult<T>[src]

impl<T: Copy> Copy for VulkanResult<T>[src]

impl<T> Debug for VulkanResult<T> where
    T: Debug
[src]

impl<T: Default> Default for VulkanResult<T>[src]

impl<T> Display for VulkanResult<T> where
    T: Display
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for VulkanResult<T> where
    T: RefUnwindSafe

impl<T> Send for VulkanResult<T> where
    T: Send

impl<T> Sync for VulkanResult<T> where
    T: Sync

impl<T> Unpin for VulkanResult<T> where
    T: Unpin

impl<T> UnwindSafe for VulkanResult<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.