Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flub committed Mar 7, 2024
1 parent a0a020f commit 84a4cf9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/high_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async fn main() {
unreachable!()
}

const HELLO: &'static [u8] = br#"HTTP/1.1 200 OK
const HELLO: &[u8] = br#"HTTP/1.1 200 OK
Content-Length: 10
Content-Type: text/plain; charset=utf-8
Expand Down
2 changes: 1 addition & 1 deletion examples/low_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async fn serve(acceptor: AcmeAcceptor, rustls_config: Arc<ServerConfig>, port: u
}
}

const HELLO: &'static [u8] = br#"HTTP/1.1 200 OK
const HELLO: &[u8] = br#"HTTP/1.1 200 OK
Content-Length: 10
Content-Type: text/plain; charset=utf-8
Expand Down
37 changes: 21 additions & 16 deletions src/state.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
use crate::acceptor::AcmeAcceptor;
use crate::acme::{
Account, AcmeError, Auth, AuthStatus, Directory, Identifier, Order, OrderStatus,
};
use crate::{AcmeConfig, Incoming, ResolvesServerCertAcme};
use chrono::{DateTime, TimeZone, Utc};
use futures::future::try_join_all;
use futures::{ready, FutureExt, Stream};
use rcgen::{CertificateParams, DistinguishedName, RcgenError, PKCS_ECDSA_P256_SHA256};
use rustls::sign::{any_ecdsa_type, CertifiedKey};
use rustls::Certificate as RustlsCertificate;
use rustls::PrivateKey;
use std::convert::Infallible;
use std::fmt::Debug;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use std::time::Duration;

use chrono::{DateTime, TimeZone, Utc};
use futures::future::try_join_all;
use futures::{ready, FutureExt, Stream};
use rcgen::{CertificateParams, DistinguishedName, RcgenError, PKCS_ECDSA_P256_SHA256};
use rustls::sign::{any_ecdsa_type, CertifiedKey};
use rustls::Certificate as RustlsCertificate;
use rustls::PrivateKey;
use thiserror::Error;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::time::Sleep;
use x509_parser::parse_x509_certificate;

use crate::acceptor::AcmeAcceptor;
use crate::acme::{
Account, AcmeError, Auth, AuthStatus, Directory, Identifier, Order, OrderStatus,
};
use crate::{AcmeConfig, Incoming, ResolvesServerCertAcme};

type Timer = std::pin::Pin<Box<Sleep>>;
type BoxFuture<T> = Pin<Box<dyn Future<Output = T> + Send>>;

pub fn after(d: std::time::Duration) -> Timer {
Box::pin(tokio::time::sleep(d))
Expand All @@ -33,10 +36,10 @@ pub struct AcmeState<EC: Debug = Infallible, EA: Debug = EC> {
resolver: Arc<ResolvesServerCertAcme>,
account_key: Option<Vec<u8>>,

early_action: Option<Pin<Box<dyn Future<Output = Event<EC, EA>> + Send>>>,
load_cert: Option<Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, EC>> + Send>>>,
load_account: Option<Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, EA>> + Send>>>,
order: Option<Pin<Box<dyn Future<Output = Result<Vec<u8>, OrderError>> + Send>>>,
early_action: Option<BoxFuture<Event<EC, EA>>>,
load_cert: Option<BoxFuture<Result<Option<Vec<u8>>, EC>>>,
load_account: Option<BoxFuture<Result<Option<Vec<u8>>, EA>>>,
order: Option<BoxFuture<Result<Vec<u8>, OrderError>>>,
backoff_cnt: usize,
wait: Option<Timer>,
}
Expand Down Expand Up @@ -178,6 +181,8 @@ impl<EC: 'static + Debug, EA: 'static + Debug> AcmeState<EC, EA> {
let cert = CertifiedKey::new(cert_chain, pk);
Ok((cert, validity))
}

#[allow(clippy::result_large_err)]
fn process_cert(&mut self, pem: Vec<u8>, cached: bool) -> Event<EC, EA> {
let (cert, validity) = match (Self::parse_cert(&pem), cached) {
(Ok(r), _) => r,
Expand Down

0 comments on commit 84a4cf9

Please sign in to comment.