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>
impl<T, B> BufResult<T, B>
Sourcepub fn map<U>(self, f: impl FnOnce(T, B) -> (U, B)) -> BufResult<U, B>
pub fn map<U>(self, f: impl FnOnce(T, B) -> (U, B)) -> BufResult<U, B>
Maps the result part, and allows updating the buffer.
Sourcepub fn map2<U, C>(
self,
f_ok: impl FnOnce(T, B) -> (U, C),
f_err: impl FnOnce(B) -> C,
) -> BufResult<U, C>
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.
Sourcepub fn map_res<U>(self, f: impl FnOnce(T) -> U) -> BufResult<U, B>
pub fn map_res<U>(self, f: impl FnOnce(T) -> U) -> BufResult<U, B>
Maps the result part, and keeps the buffer unchanged.
Sourcepub fn map_buffer<C>(self, f: impl FnOnce(B) -> C) -> BufResult<T, C>
pub fn map_buffer<C>(self, f: impl FnOnce(B) -> C) -> BufResult<T, C>
Maps the buffer part, and keeps the result unchanged.
Sourcepub fn and_then<U>(
self,
f: impl FnOnce(T, B) -> (Result<U>, B),
) -> BufResult<U, B>
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.
Trait Implementations§
Source§impl<T, B> FromResidual<BufResult<Infallible, B>> for BufResult<T, B>
Available on crate feature try_trait_v2
only.
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
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 moreSource§impl<T, B> FromResidual<BufResult<Infallible, B>> for Result<T>
Available on crate feature try_trait_v2
only.
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
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 moreSource§impl<T, B> Residual<(T, B)> for BufResult<Infallible, B>
Available on crate feature try_trait_v2
only.
impl<T, B> Residual<(T, B)> for BufResult<Infallible, B>
Available on crate feature
try_trait_v2
only.Source§impl<T, B> Try for BufResult<T, B>
Available on crate feature try_trait_v2
only.
impl<T, B> Try for BufResult<T, B>
Available on crate feature
try_trait_v2
only.Source§type Output = (T, B)
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>
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 moreSource§fn from_output((res, buf): Self::Output) -> Self
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 moreSource§fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
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 moreAuto Trait Implementations§
impl<T, B> Freeze for BufResult<T, B>
impl<T, B> !RefUnwindSafe for BufResult<T, B>
impl<T, B> Send for BufResult<T, B>
impl<T, B> Sync for BufResult<T, B>
impl<T, B> Unpin for BufResult<T, B>
impl<T, B> !UnwindSafe for BufResult<T, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more