Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HandshakeError #71

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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