use std::{fmt, ops}; use crate::{filter::Filter, Io}; /// Sealed filter type pub struct Sealed(pub(crate) Box); impl fmt::Debug for Sealed { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Sealed").finish() } } #[derive(Debug)] /// Boxed `Io` object with erased filter type pub struct IoBoxed(Io); impl IoBoxed { #[inline] /// Clone current io object. /// /// Current io object becomes closed. pub fn take(&mut self) -> Self { IoBoxed(self.0.take()) } } impl From> for IoBoxed { fn from(io: Io) -> Self { Self(io) } } impl From> for IoBoxed { fn from(io: Io) -> Self { Self(io.seal()) } } impl ops::Deref for IoBoxed { type Target = Io; #[inline] fn deref(&self) -> &Self::Target { &self.0 } }