Skip to content

Commit

Permalink
Squashed PR #397
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac committed Feb 27, 2025
1 parent 111d535 commit 7d446c6
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust_version: [default, 1.75, beta]
rust_version: [default, 1.81, beta]
fail-fast: false
timeout-minutes: 30
permissions:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tokio = { version = "1.43" }
tracing = { version = "0.1" }

[workspace.package]
rust-version = "1.75" # keep in sync with flake.nix
rust-version = "1.81" # keep in sync with flake.nix

[workspace.lints.clippy]
useless_format = 'allow'
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
devShells.minimum = pkgs.mkShell {
buildInputs = [
(fenix_pkgs.toolchainOf {
channel = "1.75"; # keep in sync with ./Cargo.toml rust-version
channel = "1.81"; # keep in sync with ./Cargo.toml rust-version
sha256 = "sha256-SXRtAuO4IqNOQq+nLbrsDFbVk+3aVA8NNpSZsKlVH/8=";
}).defaultToolchain
] ++ common;
Expand Down
2 changes: 1 addition & 1 deletion gel-auth/src/handshake/client_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl ClientAuth {
}
// SCRAM authentication: Handle SCRAM protocol messages.
(ClientAuthState::Sasl(tx, env), ClientAuthDrive::ScramResponse(message)) => {
let response = tx.process_message(&message, env)?;
let response = tx.process_message(message, env)?;
match response {
Some(response) => Ok(ClientAuthResponse::Continue(response)),
None => {
Expand Down
4 changes: 2 additions & 2 deletions gel-protocol/src/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ impl std::fmt::Display for Warning {
.as_ref()
.map(|f| format!("{f}:"))
.unwrap_or_default();
let line = line.clone().unwrap_or(1);
let col = col.clone().unwrap_or(1);
let line = (*line).unwrap_or(1);
let col = (*col).unwrap_or(1);

write!(f, "{type} at {filename}{line}:{col} {message}")
}
Expand Down
2 changes: 1 addition & 1 deletion gel-protocol/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ pub fn scalar_codec(uuid: &UuidVal) -> Result<Arc<dyn Codec>, CodecError> {
POSTGIS_GEOGRAPHY => Ok(Arc::new(PostGisGeography {})),
POSTGIS_BOX_2D => Ok(Arc::new(PostGisBox2d {})),
POSTGIS_BOX_3D => Ok(Arc::new(PostGisBox3d {})),
_ => errors::UndefinedBaseScalar { uuid: uuid.clone() }.fail()?,
_ => errors::UndefinedBaseScalar { uuid: *uuid }.fail()?,
}
}

Expand Down
2 changes: 1 addition & 1 deletion gel-protocol/src/model/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl Duration {
if seen.contains(&u) {
Err(ParseDurationError::new("specified more than once").pos(start))
} else {
seen.push(u.clone());
seen.push(u);
Ok(u)
}
})
Expand Down
34 changes: 17 additions & 17 deletions gel-protocol/src/serialization/decode/raw_scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl ScalarArg for Uuid {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Uuid(self.clone()))
Ok(Value::Uuid(*self))
}
}

Expand Down Expand Up @@ -174,7 +174,7 @@ impl ScalarArg for bool {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Bool(self.clone()))
Ok(Value::Bool(*self))
}
}

Expand All @@ -195,7 +195,7 @@ impl ScalarArg for i16 {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Int16(self.clone()))
Ok(Value::Int16(*self))
}
}

Expand All @@ -216,7 +216,7 @@ impl ScalarArg for i32 {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Int32(self.clone()))
Ok(Value::Int32(*self))
}
}

Expand Down Expand Up @@ -244,7 +244,7 @@ impl ScalarArg for i64 {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Int64(self.clone()))
Ok(Value::Int64(*self))
}
}

Expand All @@ -265,7 +265,7 @@ impl ScalarArg for f32 {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Float32(self.clone()))
Ok(Value::Float32(*self))
}
}

Expand All @@ -286,7 +286,7 @@ impl ScalarArg for f64 {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Float64(self.clone()))
Ok(Value::Float64(*self))
}
}

Expand Down Expand Up @@ -338,7 +338,7 @@ impl ScalarArg for ConfigMemory {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::ConfigMemory(self.clone()))
Ok(Value::ConfigMemory(*self))
}
}

Expand Down Expand Up @@ -497,7 +497,7 @@ impl ScalarArg for Duration {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Duration(self.clone()))
Ok(Value::Duration(*self))
}
}

Expand Down Expand Up @@ -534,7 +534,7 @@ impl ScalarArg for RelativeDuration {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::RelativeDuration(self.clone()))
Ok(Value::RelativeDuration(*self))
}
}

Expand All @@ -547,7 +547,7 @@ impl<'t> RawCodec<'t> for SystemTime {

impl ScalarArg for SystemTime {
fn encode(&self, encoder: &mut Encoder) -> Result<(), Error> {
let val = self.clone().try_into().map_err(|e| {
let val = (*self).try_into().map_err(|e| {
ClientEncodingError::with_source(e).context("cannot serialize SystemTime value")
})?;
codec::encode_datetime(encoder.buf, &val).map_err(ClientEncodingError::with_source)
Expand All @@ -556,7 +556,7 @@ impl ScalarArg for SystemTime {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
let val = self.clone().try_into().map_err(|e| {
let val = (*self).try_into().map_err(|e| {
ClientEncodingError::with_source(e).context("cannot serialize SystemTime value")
})?;
Ok(Value::Datetime(val))
Expand All @@ -578,7 +578,7 @@ impl ScalarArg for Datetime {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::Datetime(self.clone()))
Ok(Value::Datetime(*self))
}
}

Expand All @@ -597,7 +597,7 @@ impl ScalarArg for LocalDatetime {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::LocalDatetime(self.clone()))
Ok(Value::LocalDatetime(*self))
}
}

Expand All @@ -616,7 +616,7 @@ impl ScalarArg for LocalDate {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::LocalDate(self.clone()))
Ok(Value::LocalDate(*self))
}
}

Expand All @@ -641,7 +641,7 @@ impl ScalarArg for DateDuration {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::DateDuration(self.clone()))
Ok(Value::DateDuration(*self))
}
}

Expand All @@ -653,7 +653,7 @@ impl ScalarArg for LocalTime {
check_scalar(ctx, pos, Self::uuid(), Self::typename())
}
fn to_value(&self) -> Result<Value, Error> {
Ok(Value::LocalTime(self.clone()))
Ok(Value::LocalTime(*self))
}
}

Expand Down
6 changes: 3 additions & 3 deletions gel-protocol/tests/datetime_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn datetime(input: &str, micros: i64, formatted: &str) {
// assert_eq!(format!("{:?}", edgedb), formatted);

let mut buf = BytesMut::new();
let val = Value::Datetime(edgedb.clone());
let val = Value::Datetime(edgedb);
codec::Datetime.encode(&mut buf, &val).unwrap();
let serialized_micros = buf.get_i64();

Expand Down Expand Up @@ -191,7 +191,7 @@ fn datetime_pre_1970(input: StdDuration, micros: i64, output: StdDuration) {
// assert_eq!(format!("{:?}", edgedb), formatted);

let mut buf = BytesMut::new();
let val = Value::Datetime(edgedb.clone());
let val = Value::Datetime(edgedb);
codec::Datetime.encode(&mut buf, &val).unwrap();
let serialized_micros = buf.get_i64();

Expand Down Expand Up @@ -253,7 +253,7 @@ fn duration(input: StdDuration, micros: i64, output: StdDuration) {
let edgedb: Duration = input.try_into().unwrap();

let mut buf = BytesMut::new();
let val = Value::Duration(edgedb.clone());
let val = Value::Duration(edgedb);
codec::Duration.encode(&mut buf, &val).unwrap();
let serialized_micros = buf.get_i64();

Expand Down
4 changes: 2 additions & 2 deletions gel-stream/src/common/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl TlsDriver for OpensslDriver {
let webpki_roots = WEBPKI_ROOTS.get_or_init(|| {
let webpki_roots = webpki_root_certs::TLS_SERVER_ROOT_CERTS;
let mut roots = Vec::new();
for root in webpki_roots.iter().cloned() {
for root in webpki_roots {
// Don't expect the roots to fail to load
if let Ok(root) = openssl::x509::X509::from_der(root.as_ref()) {
roots.push(root);
Expand Down Expand Up @@ -352,7 +352,7 @@ impl TlsDriver for OpensslDriver {
.peer_certificate()
.map(|cert| cert.to_der())
.transpose()?;
let cert = cert.map(|cert| CertificateDer::from(cert));
let cert = cert.map(CertificateDer::from);
Ok((
TlsStream(stream),
TlsHandshake {
Expand Down
4 changes: 2 additions & 2 deletions gel-stream/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl SslError {
_ => None,
},
#[cfg(feature = "openssl")]
SslError::OpenSslErrorStack(e) => match e.errors().get(0).map(|err| err.code()) {
SslError::OpenSslErrorStack(e) => match e.errors().first().map(|err| err.code()) {
// SSL_R_WRONG_VERSION_NUMBER
Some(0xa00010b) => Some(CommonError::InvalidTlsProtocolData),
// SSL_R_PACKET_LENGTH_TOO_LONG
Expand All @@ -130,7 +130,7 @@ impl SslError {
openssl_sys::SSL_ERROR_SSL => {
match e
.ssl_error()
.and_then(|e| e.errors().get(0))
.and_then(|e| e.errors().first())
.map(|err| err.code())
{
// SSL_R_WRONG_VERSION_NUMBER
Expand Down
2 changes: 1 addition & 1 deletion gel-stream/src/server/acceptor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
common::tokio_stream::TokioListenerStream, ConnectionError, LocalAddress, ResolvedTarget,
RewindStream, Ssl, SslError, StreamUpgrade, Target, TlsDriver, TlsServerParameterProvider,
RewindStream, Ssl, SslError, StreamUpgrade, TlsDriver, TlsServerParameterProvider,
UpgradableStream,
};
use futures::{FutureExt, StreamExt};
Expand Down
4 changes: 2 additions & 2 deletions gel-stream/tests/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async fn spawn_tls_server<S: TlsDriver>(
assert_eq!(handshake.sni.as_deref(), expected_hostname.as_deref());
if validate_cert {
assert!(handshake.cert.is_some());
let cert = parse_cert(&handshake.cert.as_ref().unwrap());
let cert = parse_cert(handshake.cert.as_ref().unwrap());
let subject = cert.subject().to_string();
assert!(
subject.to_ascii_lowercase().contains("ssl_user"),
Expand Down Expand Up @@ -713,6 +713,6 @@ tls_client_test! {
fn parse_cert<'a>(
cert: &'a rustls_pki_types::CertificateDer<'a>,
) -> x509_parser::prelude::X509Certificate<'a> {
let (_, cert) = x509_parser::parse_x509_certificate(&cert).unwrap();
let (_, cert) = x509_parser::parse_x509_certificate(cert).unwrap();
cert
}
12 changes: 4 additions & 8 deletions gel-tokio/examples/transaction_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ use gel_errors::{ErrorKind, UserError};
struct CounterError;

fn check_val0(val: i64) -> anyhow::Result<()> {
if val % 3 == 0 {
if rng().random_bool(0.9) {
Err(CounterError)?;
}
if val % 3 == 0 && rng().random_bool(0.9) {
Err(CounterError)?;
}
Ok(())
}

fn check_val1(val: i64) -> Result<(), CounterError> {
if val % 3 == 1 {
if rng().random_bool(0.1) {
Err(CounterError)?;
}
if val % 3 == 1 && rng().random_bool(0.1) {
Err(CounterError)?;
}
Ok(())
}
Expand Down
38 changes: 16 additions & 22 deletions gel-tokio/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl CertCheck {
pub fn new_fn<F: Future<Output = Result<(), gel_errors::Error>> + Send + Sync + 'static>(function: impl for <'a> Fn(&'a [u8]) -> F + Send + Sync + 'static) -> Self {
let function = Arc::new(move |cert: &'_[u8]| {
let fut = function(cert);
Box::pin(async move { fut.await }) as _
Box::pin(fut) as _
});

Self { function }
Expand Down Expand Up @@ -1404,21 +1404,19 @@ impl Builder {
instance
))
})?;
if matches!(instance, InstanceName::Cloud { .. }) {
if cfg.secret_key.is_none() && cfg.cloud_profile.is_none() {
let path = stash_path.join("cloud-profile");
let profile = fs::read_to_string(&path)
.await
.map_err(|e| {
ClientError::with_source(e).context(format!(
"error reading project settings {:?}: {:?}",
project_dir, path
))
})?
.trim()
.into();
cfg.cloud_profile = Some(profile);
}
if matches!(instance, InstanceName::Cloud { .. }) && cfg.secret_key.is_none() && cfg.cloud_profile.is_none() {
let path = stash_path.join("cloud-profile");
let profile = fs::read_to_string(&path)
.await
.map_err(|e| {
ClientError::with_source(e).context(format!(
"error reading project settings {:?}: {:?}",
project_dir, path
))
})?
.trim()
.into();
cfg.cloud_profile = Some(profile);
}
read_instance(cfg, &instance).await?;
let path = stash_path.join("database");
Expand Down Expand Up @@ -1941,7 +1939,7 @@ impl Config {
tls.root_cert = TlsCert::Webpki;
match &self.0.pem_certificates {
Some(pem_certificates) => {
tls.root_cert = TlsCert::Custom(read_root_cert_pem(&pem_certificates)?);
tls.root_cert = TlsCert::Custom(read_root_cert_pem(pem_certificates)?);
}
None => {
if let Some(cloud_certs) = self.0.cloud_certs {
Expand All @@ -1967,11 +1965,7 @@ impl Config {
Some(Cow::from(host))
}
} else {
if let Some(host) = self.0.address.host() {
Some(Cow::from(host.to_string()))
} else {
None
}
self.0.address.host().map(|host| Cow::from(host.to_string()))
}
} else {
None
Expand Down
Loading

0 comments on commit 7d446c6

Please sign in to comment.