Skip to content

Commit

Permalink
Remove HandshakeError
Browse files Browse the repository at this point in the history
  • Loading branch information
msk committed Apr 4, 2024
1 parent 445e786 commit 171b72e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).

- `RequestCode::Forward` and `message::send_forward_request`, since forwarding
messages between agents is no longer supported.
- `client_handshake`, `server_handshake`, and `AgentInfo`. These belong to the
`review-protocol` crate.
- `client_handshake`, `server_handshake`, `HandshakeError`, and `AgentInfo`.
These belong to the `review-protocol` crate.

## [0.11.0] - 2024-03-25

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oinq"
version = "0.11.0"
version = "0.12.0-alpha.1"
edition = "2021"
rust-version = "1.69"
description = "The inter-agent communication protocol in the REview ecosystem"
Expand Down
31 changes: 1 addition & 30 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

use crate::frame::{self, RecvError, SendError};
use bincode::Options;
use quinn::{ConnectionError, RecvStream, SendStream};
use quinn::{RecvStream, SendStream};
use serde::Serialize;
use std::{fmt, mem};
use thiserror::Error;

/// Receives a message as a stream of bytes with a big-endian 4-byte length
/// header.
Expand Down Expand Up @@ -35,34 +34,6 @@ pub async fn recv_request_raw<'b>(
Ok((code, buf[mem::size_of::<u32>()..].as_ref()))
}

/// The error type for a handshake failure.
#[derive(Debug, Error)]
pub enum HandshakeError {
#[error("connection closed by peer")]
ConnectionClosed,
#[error("connection lost")]
ConnectionLost(#[from] ConnectionError),
#[error("cannot receive a message")]
ReadError(#[from] quinn::ReadError),
#[error("cannot send a message")]
WriteError(#[from] quinn::WriteError),
#[error("arguments are too long")]
MessageTooLarge,
#[error("invalid message")]
InvalidMessage,
#[error("protocol version {0} is not supported; version {1} is required")]
IncompatibleProtocol(String, String),
}

impl From<SendError> for HandshakeError {
fn from(e: SendError) -> Self {
match e {
SendError::MessageTooLarge => HandshakeError::MessageTooLarge,
SendError::WriteError(e) => HandshakeError::WriteError(e),
}
}
}

/// Sends a request with a big-endian 4-byte length header.
///
/// `buf` will be cleared after the response is sent.
Expand Down

0 comments on commit 171b72e

Please sign in to comment.