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

proto: make NoInitialCipherSuite Copy #1876

Merged
merged 3 commits into from
May 21, 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
2 changes: 1 addition & 1 deletion quinn-proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quinn-proto"
version = "0.11.1"
version = "0.11.2"
edition = "2021"
rust-version = "1.66"
license = "MIT OR Apache-2.0"
Expand Down
18 changes: 17 additions & 1 deletion quinn-proto/src/connection/streams/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::collections::{hash_map, BinaryHeap};
use std::{
collections::{hash_map, BinaryHeap},
io,
};

use bytes::Bytes;
use thiserror::Error;
Expand Down Expand Up @@ -443,6 +446,19 @@ pub struct ClosedStream {
_private: (),
}

impl ClosedStream {
#[doc(hidden)] // For use in quinn only
Ralith marked this conversation as resolved.
Show resolved Hide resolved
pub fn new() -> Self {
Self { _private: () }
}
}

impl From<ClosedStream> for io::Error {
fn from(x: ClosedStream) -> Self {
Self::new(io::ErrorKind::NotConnected, x)
}
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
enum StreamHalf {
Send,
Expand Down
2 changes: 1 addition & 1 deletion quinn-proto/src/crypto/rustls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl TryFrom<Arc<rustls::ClientConfig>> for QuicClientConfig {
/// [`CryptoProvider`][provider], that provider must reference a cipher suite with the same ID.
///
/// [provider]: rustls::crypto::CryptoProvider
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct NoInitialCipherSuite {
/// Whether the initial cipher suite was supplied by the caller
specific: bool,
Expand Down
2 changes: 1 addition & 1 deletion quinn-udp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quinn-udp"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
rust-version = "1.66"
license = "MIT OR Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions quinn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quinn"
version = "0.11.0"
Ralith marked this conversation as resolved.
Show resolved Hide resolved
version = "0.11.1"
license = "MIT OR Apache-2.0"
repository = "https://github.com/quinn-rs/quinn"
description = "Versatile QUIC transport protocol implementation"
Expand Down Expand Up @@ -38,7 +38,7 @@ bytes = "1"
futures-io = { version = "0.3.19", optional = true }
rustc-hash = "1.1"
pin-project-lite = "0.2"
proto = { package = "quinn-proto", path = "../quinn-proto", version = "0.11", default-features = false }
proto = { package = "quinn-proto", path = "../quinn-proto", version = "0.11.2", default-features = false }
rustls = { version = "0.23", default-features = false, features = ["ring", "std"], optional = true }
smol = { version = "2", optional = true }
thiserror = "1.0.21"
Expand Down
25 changes: 0 additions & 25 deletions quinn/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,28 +1253,3 @@ pub enum SendDatagramError {
/// This limits the amount of CPU resources consumed by datagram generation,
/// and allows other tasks (like receiving ACKs) to run in between.
const MAX_TRANSMIT_DATAGRAMS: usize = 20;

/// Error indicating that a stream has already been finished or reset
#[derive(Debug, Error, Clone, PartialEq, Eq)]
#[error("closed stream")]
pub struct ClosedStream {
_private: (),
}

impl ClosedStream {
pub(crate) fn new() -> Self {
Self { _private: () }
}
}

impl From<proto::ClosedStream> for ClosedStream {
fn from(_: proto::ClosedStream) -> Self {
Self { _private: () }
}
}

impl From<ClosedStream> for io::Error {
fn from(x: ClosedStream) -> Self {
Self::new(io::ErrorKind::NotConnected, x)
}
}
8 changes: 4 additions & 4 deletions quinn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ mod send_stream;
mod work_limiter;

pub use proto::{
congestion, crypto, AckFrequencyConfig, ApplicationClose, Chunk, ClientConfig, ConfigError,
ConnectError, ConnectionClose, ConnectionError, EndpointConfig, IdleTimeout,
congestion, crypto, AckFrequencyConfig, ApplicationClose, Chunk, ClientConfig, ClosedStream,
ConfigError, ConnectError, ConnectionClose, ConnectionError, EndpointConfig, IdleTimeout,
MtuDiscoveryConfig, ServerConfig, StreamId, Transmit, TransportConfig, VarInt,
};
#[cfg(feature = "rustls")]
pub use rustls;
pub use udp;

pub use crate::connection::{
AcceptBi, AcceptUni, ClosedStream, Connecting, Connection, OpenBi, OpenUni, ReadDatagram,
SendDatagramError, ZeroRttAccepted,
AcceptBi, AcceptUni, Connecting, Connection, OpenBi, OpenUni, ReadDatagram, SendDatagramError,
ZeroRttAccepted,
};
pub use crate::endpoint::{Accept, Endpoint};
pub use crate::incoming::{Incoming, IncomingFuture, RetryError};
Expand Down
7 changes: 2 additions & 5 deletions quinn/src/recv_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ use std::{
};

use bytes::Bytes;
use proto::{Chunk, Chunks, ConnectionError, ReadableError, StreamId};
use proto::{Chunk, Chunks, ClosedStream, ConnectionError, ReadableError, StreamId};
use thiserror::Error;
use tokio::io::ReadBuf;

use crate::{
connection::{ClosedStream, ConnectionRef},
VarInt,
};
use crate::{connection::ConnectionRef, VarInt};

/// A stream that can only be used to receive data
///
Expand Down
9 changes: 3 additions & 6 deletions quinn/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ use std::{
};

use bytes::Bytes;
use proto::{ConnectionError, FinishError, StreamId, Written};
use proto::{ClosedStream, ConnectionError, FinishError, StreamId, Written};
use thiserror::Error;

use crate::{
connection::{ClosedStream, ConnectionRef},
VarInt,
};
use crate::{connection::ConnectionRef, VarInt};

/// A stream that can only be used to send data
///
Expand Down Expand Up @@ -189,7 +186,7 @@ impl SendStream {
/// Get the priority of the send stream
pub fn priority(&self) -> Result<i32, ClosedStream> {
let mut conn = self.conn.state.lock("SendStream::priority");
Ok(conn.inner.send_stream(self.stream).priority()?)
conn.inner.send_stream(self.stream).priority()
}

/// Completes when the stream is stopped or read to completion by the peer
Expand Down