feat: add ensure_ok for simple 20/non-20 matching

This commit is contained in:
DarkCat09 2024-08-06 12:26:59 +04:00
parent 053f042e00
commit 6bd101504d
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

View file

@ -1,4 +1,4 @@
use crate::{status::Status, LibError}; use crate::{status::Status, LibError, ReplyType};
use bytes::Bytes; use bytes::Bytes;
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
@ -21,6 +21,14 @@ impl Response {
} }
} }
pub fn ensure_ok(self: Self) -> Result<Self, Self> {
if self.status.reply_type() == ReplyType::Success {
Ok(self)
} else {
Err(self)
}
}
pub fn status(self: &Self) -> Status { pub fn status(self: &Self) -> Status {
self.status self.status
} }