Struct compio_buf::BufResult

source ·
pub struct BufResult<T, B>(pub Result<T>, pub B);
Expand description

A specialized Result type for operations with buffers.

This type is used as a return value for asynchronous compio methods that require passing ownership of a buffer to the runtime. When the operation completes, the buffer is returned no matter if the operation completed successfully.

Tuple Fields§

§0: Result<T>§1: B

Implementations§

source§

impl<T, B> BufResult<T, B>

source

pub const fn is_ok(&self) -> bool

Returns true if the result is Ok.

source

pub const fn is_err(&self) -> bool

Returns true if the result is Err.

source

pub fn map<U>(self, f: impl FnOnce(T, B) -> (U, B)) -> BufResult<U, B>

Maps the result part, and allows updating the buffer.

source

pub fn map2<U, C>( self, f_ok: impl FnOnce(T, B) -> (U, C), f_err: impl FnOnce(B) -> C, ) -> BufResult<U, C>

Maps the result part, and allows changing the buffer type.

source

pub fn map_res<U>(self, f: impl FnOnce(T) -> U) -> BufResult<U, B>

Maps the result part, and keeps the buffer unchanged.

source

pub fn map_buffer<C>(self, f: impl FnOnce(B) -> C) -> BufResult<T, C>

Maps the buffer part, and keeps the result unchanged.

source

pub fn and_then<U>( self, f: impl FnOnce(T, B) -> (Result<U>, B), ) -> BufResult<U, B>

Updating the result type and modifying the buffer.

source

pub fn expect(self, msg: &str) -> (T, B)

Returns the contained Ok value, consuming the self value.

source

pub fn unwrap(self) -> (T, B)

Returns the contained Ok value, consuming the self value.

Trait Implementations§

source§

impl<T, B> From<(Result<T, Error>, B)> for BufResult<T, B>

source§

fn from((res, buf): (Result<T>, B)) -> Self

Converts to this type from the input type.
source§

impl<T, B> From<BufResult<T, B>> for (Result<T>, B)

source§

fn from(BufResult: BufResult<T, B>) -> Self

Converts to this type from the input type.
source§

impl<T, B> FromResidual<BufResult<Infallible, B>> for BufResult<T, B>

Available on crate feature try_trait_v2 only.
fn foo() -> BufResult<i32, i32> {
    let (a, b) = BufResult(Ok(1), 2)?;
    assert_eq!(a, 1);
    assert_eq!(b, 2);
    (Ok(3), 4).into()
}
assert!(foo().is_ok());
source§

fn from_residual(residual: BufResult<Infallible, B>) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
source§

impl<T, B> FromResidual<BufResult<Infallible, B>> for Result<T>

Available on crate feature try_trait_v2 only.
fn foo() -> std::io::Result<i32> {
    let (a, b) = BufResult(Ok(1), 2)?;
    assert_eq!(a, 1);
    assert_eq!(b, 2);
    Ok(3)
}
assert!(foo().is_ok());
source§

fn from_residual(residual: BufResult<Infallible, B>) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
source§

impl<T: IntoInner, O> IntoInner for BufResult<O, T>

source§

type Inner = BufResult<O, <T as IntoInner>::Inner>

The inner type.
source§

fn into_inner(self) -> Self::Inner

Get the inner buffer.
source§

impl<T, B> Residual<(T, B)> for BufResult<Infallible, B>

Available on crate feature try_trait_v2 only.
source§

type TryType = BufResult<T, B>

🔬This is a nightly-only experimental API. (try_trait_v2_residual)
The “return” type of this meta-function.
source§

impl<T, B> Try for BufResult<T, B>

Available on crate feature try_trait_v2 only.
source§

type Output = (T, B)

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value produced by ? when not short-circuiting.
source§

type Residual = BufResult<Infallible, B>

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value passed to FromResidual::from_residual as part of ? when short-circuiting. Read more
source§

fn from_output((res, buf): Self::Output) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from its Output type. Read more
source§

fn branch(self) -> ControlFlow<Self::Residual, Self::Output>

🔬This is a nightly-only experimental API. (try_trait_v2)
Used in ? to decide whether the operator should produce a value (because this returned ControlFlow::Continue) or propagate a value back to the caller (because this returned ControlFlow::Break). Read more

Auto Trait Implementations§

§

impl<T, B> Freeze for BufResult<T, B>
where B: Freeze, T: Freeze,

§

impl<T, B> !RefUnwindSafe for BufResult<T, B>

§

impl<T, B> Send for BufResult<T, B>
where B: Send, T: Send,

§

impl<T, B> Sync for BufResult<T, B>
where B: Sync, T: Sync,

§

impl<T, B> Unpin for BufResult<T, B>
where B: Unpin, T: Unpin,

§

impl<T, B> !UnwindSafe for BufResult<T, B>

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.