fix: finally, async-trait works

This commit is contained in:
DarkCat09 2024-08-21 16:01:21 +04:00
parent e042a139bf
commit 49c46aeaf5
Signed by: DarkCat09
GPG key ID: BD3CE9B65916CD82
3 changed files with 10 additions and 6 deletions

View file

@ -1,3 +1,4 @@
use async_trait::async_trait;
use tokio_gemini::{ use tokio_gemini::{
certs::{ certs::{
dane, file_sscv::KnownHostsFile, fingerprint::CertFingerprint, SelfsignedCertVerifier, dane, file_sscv::KnownHostsFile, fingerprint::CertFingerprint, SelfsignedCertVerifier,
@ -120,10 +121,11 @@ struct CertVerifier {
dns: Option<DnsClient>, dns: Option<DnsClient>,
} }
#[async_trait]
impl SelfsignedCertVerifier for CertVerifier { impl SelfsignedCertVerifier for CertVerifier {
async fn verify<'c>( async fn verify(
&self, &self,
cert: &'c tokio_gemini::certs::CertificateDer<'c>, cert: &tokio_gemini::certs::CertificateDer<'_>,
host: &str, host: &str,
port: u16, port: u16,
) -> Result<bool, tokio_gemini::LibError> { ) -> Result<bool, tokio_gemini::LibError> {

View file

@ -1,3 +1,4 @@
use async_trait::async_trait;
use tokio_gemini::{ use tokio_gemini::{
certs::{fingerprint::CertFingerprint, SelfsignedCertVerifier}, certs::{fingerprint::CertFingerprint, SelfsignedCertVerifier},
Client, LibError, Client, LibError,
@ -32,10 +33,11 @@ async fn main() -> Result<(), LibError> {
struct CertVerifier; struct CertVerifier;
#[async_trait]
impl SelfsignedCertVerifier for CertVerifier { impl SelfsignedCertVerifier for CertVerifier {
async fn verify<'c>( async fn verify(
&self, &self,
cert: &'c tokio_gemini::certs::CertificateDer<'c>, cert: &tokio_gemini::certs::CertificateDer<'_>,
host: &str, host: &str,
port: u16, port: u16,
) -> Result<bool, tokio_gemini::LibError> { ) -> Result<bool, tokio_gemini::LibError> {

View file

@ -17,9 +17,9 @@ pub use tokio_rustls::rustls::pki_types::{CertificateDer, ServerName, UnixTime};
/// It is recommended to use helpers from file_sscv. /// It is recommended to use helpers from file_sscv.
#[async_trait] #[async_trait]
pub trait SelfsignedCertVerifier: Send + Sync { pub trait SelfsignedCertVerifier: Send + Sync {
async fn verify<'c>( async fn verify(
&self, &self,
cert: &'c CertificateDer<'c>, cert: &CertificateDer<'_>,
host: &str, host: &str,
port: u16, port: u16,
// now: UnixTime, // now: UnixTime,