use std::fmt; use std::ops::{Deref, DerefMut}; use actix_codec::{Decoder, Encoder}; use crate::sink::Sink; pub struct Item { state: St, sink: Sink<::Item, E>, item: ::Item, } impl Item where Codec: Encoder + Decoder, { pub(crate) fn new( state: St, sink: Sink<::Item, E>, item: ::Item, ) -> Self { Item { state, sink, item } } #[inline] pub fn state(&self) -> &St { &self.state } #[inline] pub fn state_mut(&mut self) -> &mut St { &mut self.state } #[inline] pub fn sink(&self) -> &Sink<::Item, E> { &self.sink } #[inline] pub fn into_inner(self) -> ::Item { self.item } #[inline] pub fn into_parts( self, ) -> ( St, Sink<::Item, E>, ::Item, ) { (self.state, self.sink, self.item) } } impl Deref for Item where Codec: Encoder + Decoder, { type Target = ::Item; #[inline] fn deref(&self) -> &::Item { &self.item } } impl DerefMut for Item where Codec: Encoder + Decoder, { #[inline] fn deref_mut(&mut self) -> &mut ::Item { &mut self.item } } impl fmt::Debug for Item where Codec: Encoder + Decoder, ::Item: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Item").field(&self.item).finish() } }