pub struct BufResult<T, B>(pub Result<T, Error>, 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, Error>
§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, Error>, B),
) -> BufResult<U, B>
pub fn and_then<U>( self, f: impl FnOnce(T, B) -> (Result<U, Error>, B), ) -> BufResult<U, B>
Updating the result type and modifying the buffer.
Trait Implementations§
Source§impl<T, O> BufResultExt for BufResult<(usize, O), T>where
T: SetBufInit,
impl<T, O> BufResultExt for BufResult<(usize, O), T>where
T: SetBufInit,
Source§fn map_advanced(self) -> BufResult<(usize, O), T>
fn map_advanced(self) -> BufResult<(usize, O), T>
Call
SetBufInit::set_buf_init
if the result is Ok
.Source§impl<T, C, O> BufResultExt for BufResult<(usize, usize, O), (T, C)>where
T: SetBufInit,
C: SetBufInit,
impl<T, C, O> BufResultExt for BufResult<(usize, usize, O), (T, C)>where
T: SetBufInit,
C: SetBufInit,
Source§fn map_advanced(self) -> BufResult<(usize, usize, O), (T, C)>
fn map_advanced(self) -> BufResult<(usize, usize, O), (T, C)>
Call
SetBufInit::set_buf_init
if the result is Ok
.Source§impl<T> BufResultExt for BufResult<usize, T>where
T: SetBufInit,
impl<T> BufResultExt for BufResult<usize, T>where
T: SetBufInit,
Source§fn map_advanced(self) -> BufResult<usize, T>
fn map_advanced(self) -> BufResult<usize, T>
Call
SetBufInit::set_buf_init
if the result is Ok
.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());
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>) -> BufResult<T, B>
fn from_residual(residual: BufResult<Infallible, B>) -> BufResult<T, B>
🔬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, Error>
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());
impl<T, B> FromResidual<BufResult<Infallible, B>> for Result<T, Error>
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>) -> Result<T, Error>
fn from_residual(residual: BufResult<Infallible, B>) -> Result<T, Error>
🔬This is a nightly-only experimental API. (
try_trait_v2
)Constructs the type from a compatible
Residual
type. Read moreSource§impl<T> RecvResultExt for BufResult<usize, (T, sockaddr_storage, u32)>
impl<T> RecvResultExt for BufResult<usize, (T, sockaddr_storage, u32)>
Source§fn map_addr(
self,
) -> <BufResult<usize, (T, sockaddr_storage, u32)> as RecvResultExt>::RecvResult
fn map_addr( self, ) -> <BufResult<usize, (T, sockaddr_storage, u32)> as RecvResultExt>::RecvResult
Source§impl<T> RecvResultExt for BufResult<usize, (T, sockaddr_storage, u32, usize)>
impl<T> RecvResultExt for BufResult<usize, (T, sockaddr_storage, u32, usize)>
Source§fn map_addr(
self,
) -> <BufResult<usize, (T, sockaddr_storage, u32, usize)> as RecvResultExt>::RecvResult
fn map_addr( self, ) -> <BufResult<usize, (T, sockaddr_storage, u32, usize)> as RecvResultExt>::RecvResult
Source§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(_: <BufResult<T, B> as Try>::Output) -> BufResult<T, B>
fn from_output(_: <BufResult<T, B> as Try>::Output) -> BufResult<T, B>
🔬This is a nightly-only experimental API. (
try_trait_v2
)Constructs the type from its
Output
type. Read moreSource§fn branch(
self,
) -> ControlFlow<<BufResult<T, B> as Try>::Residual, <BufResult<T, B> as Try>::Output>
fn branch( self, ) -> ControlFlow<<BufResult<T, B> as Try>::Residual, <BufResult<T, B> as Try>::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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more