diff --git a/src/response.rs b/src/response.rs index 0da2940..32eb0db 100644 --- a/src/response.rs +++ b/src/response.rs @@ -1,4 +1,4 @@ -use crate::{status::Status, LibError}; +use crate::{status::Status, LibError, ReplyType}; use bytes::Bytes; use tokio::io::AsyncReadExt; @@ -21,6 +21,14 @@ impl Response { } } + pub fn ensure_ok(self: Self) -> Result { + if self.status.reply_type() == ReplyType::Success { + Ok(self) + } else { + Err(self) + } + } + pub fn status(self: &Self) -> Status { self.status }