Skip to main content

PokeResult

Struct PokeResult 

Source
pub struct PokeResult<'mem, 'facet> { /* private fields */ }
Expand description

Lets you mutate a result (implements mutable result operations)

Implementations§

Source§

impl<'mem, 'facet> PokeResult<'mem, 'facet>

Source

pub const unsafe fn new(value: Poke<'mem, 'facet>, def: ResultDef) -> Self

Creates a new poke result

§Safety

The caller must ensure that def contains valid vtable function pointers that correctly implement the result operations for the actual type, and that the ok/err types match def.t() / def.e().

Source

pub const fn def(&self) -> ResultDef

Returns the result definition

Source

pub const fn vtable(&self) -> &'static ResultVTable

Returns the result vtable

Source

pub fn is_ok(&self) -> bool

Returns whether the result is Ok

Source

pub fn is_err(&self) -> bool

Returns whether the result is Err

Source

pub fn ok(&self) -> Option<Peek<'_, 'facet>>

Returns the Ok value as a read-only Peek if the result is Ok, None otherwise.

Source

pub fn err(&self) -> Option<Peek<'_, 'facet>>

Returns the Err value as a read-only Peek if the result is Err, None otherwise.

Source

pub fn ok_mut(&mut self) -> Option<Poke<'_, 'facet>>

Returns the Ok value as a mutable Poke if the result is Ok, None otherwise.

Source

pub fn err_mut(&mut self) -> Option<Poke<'_, 'facet>>

Returns the Err value as a mutable Poke if the result is Err, None otherwise.

Source

pub fn set_ok<T: Facet<'facet>>(&mut self, value: T) -> Result<(), ReflectError>

Sets the result to Ok(value), dropping the previous value.

Source

pub fn set_err<E: Facet<'facet>>( &mut self, value: E, ) -> Result<(), ReflectError>

Sets the result to Err(value), dropping the previous value.

Source

pub fn set_ok_from_heap<const BORROW: bool>( &mut self, value: HeapValue<'facet, BORROW>, ) -> Result<(), ReflectError>

Type-erased set_ok.

Accepts a HeapValue whose shape must match the result’s Ok type.

Source

pub fn set_err_from_heap<const BORROW: bool>( &mut self, value: HeapValue<'facet, BORROW>, ) -> Result<(), ReflectError>

Type-erased set_err.

Accepts a HeapValue whose shape must match the result’s Err type.

Source

pub const fn into_inner(self) -> Poke<'mem, 'facet>

Converts this PokeResult back into a Poke

Source

pub fn as_peek_result(&self) -> PeekResult<'_, 'facet>

Returns a read-only PeekResult view

Trait Implementations§

Source§

impl<'mem, 'facet> Debug for PokeResult<'mem, 'facet>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'mem, 'facet> Freeze for PokeResult<'mem, 'facet>

§

impl<'mem, 'facet> RefUnwindSafe for PokeResult<'mem, 'facet>

§

impl<'mem, 'facet> !Send for PokeResult<'mem, 'facet>

§

impl<'mem, 'facet> !Sync for PokeResult<'mem, 'facet>

§

impl<'mem, 'facet> Unpin for PokeResult<'mem, 'facet>

§

impl<'mem, 'facet> UnsafeUnpin for PokeResult<'mem, 'facet>

§

impl<'mem, 'facet> !UnwindSafe for PokeResult<'mem, 'facet>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.