use crate::{Clock, Duty, EmbeddedHost, HostSnapshot, Waiter};
use super::{ReactorOutcome, ReactorSnapshot};
type ReactorParts<D, C, W> = (
EmbeddedHost<D, C>,
W,
ReactorOutcome<<D as Duty>::Error, <C as Clock>::Error, <W as Waiter<D>>::Error>,
ReactorSnapshot,
);
#[derive(Debug)]
pub struct ReactorExit<D, C, W>
where
D: Duty,
C: Clock,
W: Waiter<D>,
{
pub(super) host: EmbeddedHost<D, C>,
pub(super) waiter: W,
pub(super) outcome: ReactorOutcome<D::Error, C::Error, W::Error>,
pub(super) snapshot: ReactorSnapshot,
}
impl<D, C, W> ReactorExit<D, C, W>
where
D: Duty,
C: Clock,
W: Waiter<D>,
{
pub const fn outcome(&self) -> &ReactorOutcome<D::Error, C::Error, W::Error> {
&self.outcome
}
pub const fn host_snapshot(&self) -> HostSnapshot {
self.host.snapshot()
}
pub const fn reactor_snapshot(&self) -> ReactorSnapshot {
self.snapshot
}
pub const fn duty(&self) -> &D {
self.host.duty()
}
pub const fn waiter(&self) -> &W {
&self.waiter
}
pub fn into_parts(self) -> ReactorParts<D, C, W> {
(self.host, self.waiter, self.outcome, self.snapshot)
}
pub fn into_duty(self) -> D {
self.host.into_duty()
}
}