Compare commits

..

1 commit

Author SHA1 Message Date
874fa91186
Switch to my fork 2022-06-30 14:48:56 +02:00
5 changed files with 1 additions and 27 deletions

View file

@ -14,7 +14,7 @@ tracing = "0.1"
tracing-futures = "0.2" tracing-futures = "0.2"
# IMAP # IMAP
imap-codec = "0.5" imap-codec = { git = "https://github.com/superboum/imap-codec.git", branch = "v0.5.x" }
# Async # Async
async-compat = "0.2" async-compat = "0.2"

View file

@ -70,7 +70,6 @@ impl fmt::Debug for Body {
pub enum Data { pub enum Data {
Data(ImapData), Data(ImapData),
Status(ImapStatus), Status(ImapStatus),
Close,
} }
impl Encode for Data { impl Encode for Data {
@ -78,7 +77,6 @@ impl Encode for Data {
match self { match self {
Data::Data(ref data) => data.encode(writer), Data::Data(ref data) => data.encode(writer),
Data::Status(ref status) => status.encode(writer), Data::Status(ref status) => status.encode(writer),
Data::Close => Ok(()),
} }
} }
} }

View file

@ -13,7 +13,6 @@ pub(crate) mod stream;
pub struct Response { pub struct Response {
pub(crate) status: Status, pub(crate) status: Status,
pub(crate) body: Option<Body>, pub(crate) body: Option<Body>,
pub(crate) close: bool,
} }
impl Response { impl Response {
@ -21,7 +20,6 @@ impl Response {
Ok(Response { Ok(Response {
status: Status::new(code, msg)?, status: Status::new(code, msg)?,
body: None, body: None,
close: false,
}) })
} }
@ -52,11 +50,6 @@ impl Response {
self.body = Some(body.into()); self.body = Some(body.into());
self self
} }
pub fn close(mut self, close: bool) -> Self {
self.close = close;
self
}
} }
impl Response { impl Response {

View file

@ -5,7 +5,6 @@ use super::body::Data;
use super::Response; use super::Response;
pub fn response_stream(res: Response, tag: Option<Tag>) -> impl Stream<Item = Data> { pub fn response_stream(res: Response, tag: Option<Tag>) -> impl Stream<Item = Data> {
let close = res.close;
let (body, status) = res.split(); let (body, status) = res.split();
let body = body.map(|body| body.into_stream()); let body = body.map(|body| body.into_stream());
@ -20,9 +19,5 @@ pub fn response_stream(res: Response, tag: Option<Tag>) -> impl Stream<Item = Da
let item = status.into_imap(tag); let item = status.into_imap(tag);
tracing::trace!(?item, "response_stream.yield"); tracing::trace!(?item, "response_stream.yield");
yield item.into(); yield item.into();
if close {
yield Data::Close;
}
} }
} }

View file

@ -23,8 +23,6 @@ pub struct Connection<C> {
#[pin] #[pin]
outbox: ConcatAll<BoxStream<'static, Data>>, outbox: ConcatAll<BoxStream<'static, Data>>,
write_buf: BytesMut, write_buf: BytesMut,
close: bool,
} }
impl<C> Connection<C> { impl<C> Connection<C> {
@ -36,8 +34,6 @@ impl<C> Connection<C> {
outbox: ConcatAll::new(), outbox: ConcatAll::new(),
write_buf: BytesMut::new(), write_buf: BytesMut::new(),
close: false,
} }
} }
} }
@ -109,10 +105,6 @@ where
while let Poll::Ready(Some(data)) = this.outbox.as_mut().poll_next(cx) { while let Poll::Ready(Some(data)) = this.outbox.as_mut().poll_next(cx) {
tracing::trace!(?data, "transport.write_buf"); tracing::trace!(?data, "transport.write_buf");
if let Data::Close = data {
*this.close = true;
}
if let Err(err) = data.encode(&mut writer) { if let Err(err) = data.encode(&mut writer) {
tracing::error!(?err, "transport.encode_error"); tracing::error!(?err, "transport.encode_error");
return Poll::Ready(Err(Box::new(err))); return Poll::Ready(Err(Box::new(err)));
@ -126,10 +118,6 @@ where
} }
this.write_buf.clear(); this.write_buf.clear();
if *this.close {
futures::ready!(this.conn.as_mut().poll_close(cx))?;
}
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
} }