mod protocol;
pub use protocol::*;
use reqwest::ClientBuilder;
const USER_AGENT: &str = "PDF Rust Client Library";
pub async fn pdf<S: AsRef<str>>(
server: S,
spec: &DocumentSpecification,
) -> Result<Vec<u8>, reqwest::Error> {
Ok(ClientBuilder::new()
.user_agent(USER_AGENT)
.build()
.unwrap()
.get(format!("{}/generate", server.as_ref()))
.json(spec)
.send()
.await?
.error_for_status()?
.bytes()
.await?
.to_vec())
}
#[cfg(feature = "blocking")]
pub mod blocking {
use crate::{DocumentSpecification, USER_AGENT};
use reqwest::blocking::ClientBuilder;
pub fn pdf<S: AsRef<str>>(
server: S,
spec: &DocumentSpecification,
) -> Result<Vec<u8>, reqwest::Error> {
Ok(ClientBuilder::new()
.user_agent(USER_AGENT)
.build()
.unwrap()
.get(format!("{}/generate", server.as_ref()))
.json(spec)
.send()?
.error_for_status()?
.bytes()?
.to_vec())
}
}