pub struct ReqwestClient<Crypto> { /* private fields */ }Expand description
A Repo and Deliver type backed by reqwest
This client is generic over it’s Cryptography. It signs it’s requests with HTTP Signatures, and computes digests of it’s request bodies.
use apub_reqwest::{ReqwestClient, SignatureConfig};
use apub_rustcrypto::Rustcrypto;
use reqwest_middleware::ClientBuilder;
use rsa::RsaPrivateKey;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let private_key = RsaPrivateKey::new(&mut rand::thread_rng(), 1024)?;
let crypto = Rustcrypto::new("key-id".to_string(), private_key);
let signature_config = SignatureConfig::default();
let client = reqwest::Client::new();
let client = ClientBuilder::new(client).build();
let reqwest_client = ReqwestClient::new(client, signature_config, &crypto);
Ok(())
}Implementations§
Source§impl<Crypto> ReqwestClient<Crypto>
impl<Crypto> ReqwestClient<Crypto>
Sourcepub fn new(
client: ClientWithMiddleware,
config: SignatureConfig,
crypto: Crypto,
) -> Self
pub fn new( client: ClientWithMiddleware, config: SignatureConfig, crypto: Crypto, ) -> Self
Create a new Client & Repo implementation backed by the reqwest client
Trait Implementations§
Source§impl<Crypto> Deliver for ReqwestClient<Crypto>where
Crypto: DigestFactory + PrivateKey + Send + Sync,
<Crypto as DigestFactory>::Digest: DigestBuilder + Clone,
<<Crypto as PrivateKey>::Signer as Sign>::Error: Error,
impl<Crypto> Deliver for ReqwestClient<Crypto>where
Crypto: DigestFactory + PrivateKey + Send + Sync,
<Crypto as DigestFactory>::Digest: DigestBuilder + Clone,
<<Crypto as PrivateKey>::Signer as Sign>::Error: Error,
Source§type Error = ReqwestError<<<Crypto as PrivateKey>::Signer as Sign>::Error>
type Error = ReqwestError<<<Crypto as PrivateKey>::Signer as Sign>::Error>
Errors produced by the client
Source§impl<Crypto> Repo for ReqwestClient<Crypto>
impl<Crypto> Repo for ReqwestClient<Crypto>
Source§type Error = ReqwestError<<<Crypto as PrivateKey>::Signer as Sign>::Error>
type Error = ReqwestError<<<Crypto as PrivateKey>::Signer as Sign>::Error>
The Error produced by fetching an object
Source§fn fetch<'life0, 'async_trait, D, S>(
&'life0 self,
id: D,
session: S,
) -> Pin<Box<dyn Future<Output = Result<Option<D::Output>, Self::Error>> + 'async_trait>>where
D: 'async_trait + Dereference,
S: 'async_trait + Session,
Self: 'async_trait,
'life0: 'async_trait,
fn fetch<'life0, 'async_trait, D, S>(
&'life0 self,
id: D,
session: S,
) -> Pin<Box<dyn Future<Output = Result<Option<D::Output>, Self::Error>> + 'async_trait>>where
D: 'async_trait + Dereference,
S: 'async_trait + Session,
Self: 'async_trait,
'life0: 'async_trait,
Fetch the object from the repository
Auto Trait Implementations§
impl<Crypto> Freeze for ReqwestClient<Crypto>where
Crypto: Freeze,
impl<Crypto> !RefUnwindSafe for ReqwestClient<Crypto>
impl<Crypto> Send for ReqwestClient<Crypto>where
Crypto: Send,
impl<Crypto> Sync for ReqwestClient<Crypto>where
Crypto: Sync,
impl<Crypto> Unpin for ReqwestClient<Crypto>where
Crypto: Unpin,
impl<Crypto> !UnwindSafe for ReqwestClient<Crypto>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more