pub struct Response<Res> {
pub inner: Result<Res, Error>,
pub task_id: TaskId,
pub attempt: Attempt,
/* private fields */
}
Expand description
A generic Response
struct that wraps the result of a task, containing the outcome (Ok
or Err
),
task metadata such as task_id
, attempt
, and an internal marker field for future extensions.
§Type Parameters
Res
: The successful result type of the response.
§Fields
inner
: AResult
that holds either the success value of typeRes
or anError
on failure.task_id
: ATaskId
representing the unique identifier for the task.attempt
: AnAttempt
representing how many attempts were made to complete the task._priv
: A private marker field to prevent external construction of theResponse
.
Fields§
§inner: Result<Res, Error>
The result from a task
task_id: TaskId
The task id
attempt: Attempt
The current attempt
Implementations§
Source§impl<Res> Response<Res>
impl<Res> Response<Res>
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Checks if the Response
contains a success (Ok
).
§Returns
true
if the Response
is successful, false
otherwise.
Sourcepub fn is_failure(&self) -> bool
pub fn is_failure(&self) -> bool
Checks if the Response
contains a failure (Err
).
§Returns
true
if the Response
is a failure, false
otherwise.
Sourcepub fn map<F, T>(&self, f: F) -> Response<T>
pub fn map<F, T>(&self, f: F) -> Response<T>
Maps the success value (Res
) of the Response
to another type using the provided function.
§Arguments
f
: A function that takes a reference to the success value and returns a new value of typeT
.
§Returns
A new Response
with the transformed success value or the same error.
§Type Parameters
F
: A function or closure that takes a reference to a value of typeRes
and returns a value of typeT
.T
: The new type of the success value after mapping.
Trait Implementations§
Auto Trait Implementations§
impl<Res> Freeze for Response<Res>where
Res: Freeze,
impl<Res> !RefUnwindSafe for Response<Res>
impl<Res> Send for Response<Res>where
Res: Send,
impl<Res> Sync for Response<Res>where
Res: Sync,
impl<Res> Unpin for Response<Res>where
Res: Unpin,
impl<Res> !UnwindSafe for Response<Res>
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