~admicos/moonlander

dde394f1b7b8076ad1de98045f46460e524af11c — Ecmel Berk Canlier 20 days ago 11ea1ee main
gemini: Make clippy happy
4 files changed, 11 insertions(+), 11 deletions(-)

M gemini/src/error.rs
M gemini/src/header.rs
M gemini/src/lib.rs
M moonlander/src/network/geminix.rs
M gemini/src/error.rs => gemini/src/error.rs +5 -5
@@ 1,16 1,16 @@
#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("URL has no scheme, and adding the automatic gemini:// scheme has failed")]
    URLSchemeError,
    UrlSchemeError,

    #[error("no hostname found in URL {0}")]
    URLNoHostError(String),
    UrlNoHostError(String),

    #[error("invalid hostname in url")]
    URLInvalidHostError(#[from] webpki::InvalidDNSNameError),
    UrlInvalidHostError(#[from] webpki::InvalidDNSNameError),

    #[error("IO error")]
    IOError(#[from] std::io::Error),
    IoError(#[from] std::io::Error),

    #[error("Untrusted certificate for {host}\n    The server might have changed certificates.\n    Currently trusting ({algorithm}) {expected_fingerprint}")]
    UntrustedCertificate {


@@ 32,7 32,7 @@ pub enum Error {
    ResponseInvalidHeaderNoMeta(u8),

    #[error("TLS Error")]
    TLSError(#[from] rustls::TLSError),
    TlsError(#[from] rustls::TLSError),
}

pub type Result<T> = std::result::Result<T, Error>;

M gemini/src/header.rs => gemini/src/header.rs +3 -3
@@ 4,7 4,7 @@ use crate::{Error, Result};
#[derive(Eq, PartialEq, Clone, Debug)]
pub enum FailTempDetails {
    ServerUnavailable = 41,
    CGIError = 42,
    CgiError = 42,
    ProxyError = 43,
    SlowDown = 44,
}


@@ 147,7 147,7 @@ impl Header {
            Self::FailTemp { details, why: _ } => match details {
                None => 40,
                Some(FailTempDetails::ServerUnavailable) => 41,
                Some(FailTempDetails::CGIError) => 42,
                Some(FailTempDetails::CgiError) => 42,
                Some(FailTempDetails::ProxyError) => 43,
                Some(FailTempDetails::SlowDown) => 44,
            },


@@ 230,7 230,7 @@ impl Header {
                why: meta,
            },
            42 => Self::FailTemp {
                details: Some(FailTempDetails::CGIError),
                details: Some(FailTempDetails::CgiError),
                why: meta,
            },
            43 => Self::FailTemp {

M gemini/src/lib.rs => gemini/src/lib.rs +2 -2
@@ 82,7 82,7 @@ pub fn request(url: &url::Url, callback: impl Fn(Chunk) -> ChunkResponse) -> Res
    let mut url = url.clone();
    if url.scheme().is_empty() {
        url.set_scheme("gemini")
            .map_err(|_| error::Error::URLSchemeError)?;
            .map_err(|_| error::Error::UrlSchemeError)?;
    }

    // Do not send a fragment to the server


@@ 93,7 93,7 @@ pub fn request(url: &url::Url, callback: impl Fn(Chunk) -> ChunkResponse) -> Res
    let port = url.port().unwrap_or(DEFAULT_PORT);
    let host = url
        .host_str()
        .ok_or_else(|| error::Error::URLNoHostError(url.to_string()))?;
        .ok_or_else(|| error::Error::UrlNoHostError(url.to_string()))?;

    let tls_config = {
        Arc::new({

M moonlander/src/network/geminix.rs => moonlander/src/network/geminix.rs +1 -1
@@ 64,7 64,7 @@ impl NetworkConnector {
                Ok(Chunk::Header(Header::FailTemp { details, why })) => {
                    let details = details.map_or("Temporary Error", |d| match d {
                        FailTempDetails::ServerUnavailable => "Server Unavailable",
                        FailTempDetails::CGIError => "CGI Error",
                        FailTempDetails::CgiError => "CGI Error",
                        FailTempDetails::ProxyError => "Proxy Error",
                        FailTempDetails::SlowDown => "Slow Down",
                    });