use crate::double_checked::execution_result::ExecutionResult;
pub struct ExecutionContext<T, E>
where
E: std::fmt::Display,
{
result: ExecutionResult<T, E>,
}
impl<T, E> ExecutionContext<T, E>
where
E: std::fmt::Display,
{
#[inline]
pub(super) fn new(result: ExecutionResult<T, E>) -> Self {
Self { result }
}
#[inline]
pub fn get_result(self) -> ExecutionResult<T, E> {
self.result
}
#[inline]
pub fn peek_result(&self) -> &ExecutionResult<T, E> {
&self.result
}
#[inline]
pub fn is_success(&self) -> bool {
self.result.is_success()
}
}
impl<E> ExecutionContext<(), E>
where
E: std::fmt::Display,
{
#[inline]
pub fn finish(self) -> bool {
let result = self.get_result();
result.is_success()
}
}