feat: add ensure_ok for simple 20/non-20 matching
This commit is contained in:
parent
053f042e00
commit
6bd101504d
1 changed files with 9 additions and 1 deletions
|
@ -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<Self, Self> {
|
||||
if self.status.reply_type() == ReplyType::Success {
|
||||
Ok(self)
|
||||
} else {
|
||||
Err(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn status(self: &Self) -> Status {
|
||||
self.status
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue