mirror of
https://github.com/str4d/rage.git
synced 2025-04-04 11:27:43 +03:00
age-core: Expose unsupported
bidir response as Error::Unsupported
This commit is contained in:
parent
8032c75707
commit
abc2d978db
2 changed files with 11 additions and 2 deletions
|
@ -9,11 +9,16 @@ to 1.0.0 are beta releases.
|
|||
## [Unreleased]
|
||||
### Added
|
||||
- `age_core::io::{DebugReader, DebugWriter}`
|
||||
- `age_core::plugin::Error::Unsupported`
|
||||
|
||||
### Changed
|
||||
- MSRV is now 1.56.0.
|
||||
- `Connection::open` now returns the debugging-friendly concrete type
|
||||
`Connection<DebugReader<ChildStdout>, DebugWriter<ChildStdin>>`.
|
||||
- `age_core::plugin`:
|
||||
- `Connection::open` now returns the debugging-friendly concrete type
|
||||
`Connection<DebugReader<ChildStdout>, DebugWriter<ChildStdin>>`.
|
||||
- `BidirSend::{send, send_stanza}` now return `Ok(Error::Unsupported)` when an
|
||||
`unsupported` response is received, instead of `Err(io::Error)`, making it
|
||||
easier for plugins to implement fallback strategies.
|
||||
|
||||
## [0.7.1] - 2021-12-27
|
||||
### Fixed
|
||||
|
|
|
@ -29,12 +29,14 @@ const RESPONSE_UNSUPPORTED: &str = "unsupported";
|
|||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Fail,
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Fail => write!(f, "General plugin protocol error"),
|
||||
Self::Unsupported => write!(f, "Unsupported command"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -335,6 +337,7 @@ impl<'a, R: Read, W: Write> BidirSend<'a, R, W> {
|
|||
match s.tag.as_ref() {
|
||||
RESPONSE_OK => Ok(Ok(s)),
|
||||
RESPONSE_FAIL => Ok(Err(Error::Fail)),
|
||||
RESPONSE_UNSUPPORTED => Ok(Err(Error::Unsupported)),
|
||||
tag => Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
format!("unexpected response: {}", tag),
|
||||
|
@ -358,6 +361,7 @@ impl<'a, R: Read, W: Write> BidirSend<'a, R, W> {
|
|||
match s.tag.as_ref() {
|
||||
RESPONSE_OK => Ok(Ok(s)),
|
||||
RESPONSE_FAIL => Ok(Err(Error::Fail)),
|
||||
RESPONSE_UNSUPPORTED => Ok(Err(Error::Unsupported)),
|
||||
tag => Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
format!("unexpected response: {}", tag),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue