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 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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue