pub struct HttpTransport { /* private fields */ }Expand description
A Transport that talks to the TypeSafe API over HTTPS.
- TLS is
rustlswith the operating system’s certificate verifier. Verification cannot be switched off, and a plainhttp://base URL is only possible as described onBaseUrl. - Redirects are not followed, so the API key is never forwarded to another host.
- Failures are retried as the
RetryPolicysays, which by default matches the official SDKs. - At
DEBUGlevel it traces the method, URL, status, timing, request id and every retry decision. Bodies are traced only afterHttpTransportBuilder::log_bodies, because a request’sstateis often customer data. TheAuthorizationheader is never traced.
It must be used inside a Tokio runtime.
use jev_client::{ApiKey, HttpTransport, Noul, Request, Transport};
let key = ApiKey::new(std::env::var("TYPESAFE_API_KEY")?)?;
let transport = HttpTransport::builder(key).build()?;
let request = Request::new("Help! My payouts have been failing for 3 days.", "jev-latest")
.question("is_urgent", Noul::new("Does this convey urgency?"));
let reply = transport.evaluate(&request).await?;
println!("{} answered in {:?}", reply.body.model, reply.meta.latency);Implementations§
Source§impl HttpTransport
impl HttpTransport
Sourcepub fn builder(api_key: ApiKey) -> HttpTransportBuilder
pub fn builder(api_key: ApiKey) -> HttpTransportBuilder
Starts building a transport that authenticates with api_key.
Sourcepub const fn retry_policy(&self) -> &RetryPolicy
pub const fn retry_policy(&self) -> &RetryPolicy
The retry policy in force.
Sourcepub fn with_throttle(self, throttle: Arc<Throttle>) -> Self
pub fn with_throttle(self, throttle: Arc<Throttle>) -> Self
Paces every call through this transport, and its clones, with throttle: a 429 or 529 on
one call then slows all of them. Share one Throttle between transports to pace them
together.
Trait Implementations§
Source§impl Clone for HttpTransport
impl Clone for HttpTransport
Source§impl Debug for HttpTransport
impl Debug for HttpTransport
Auto Trait Implementations§
impl !Freeze for HttpTransport
impl !RefUnwindSafe for HttpTransport
impl !UnwindSafe for HttpTransport
impl Send for HttpTransport
impl Sync for HttpTransport
impl Unpin for HttpTransport
impl UnsafeUnpin for HttpTransport
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