pub struct BaseUrl { /* private fields */ }Expand description
The root URL of the TypeSafe API, such as https://api.typesafe.ai.
A base URL must use https://. Plain http:// is accepted for a loopback address, which is
what a local mock server uses, and otherwise only through
BaseUrl::parse_allowing_insecure_http, an explicit opt-in. A URL carrying credentials, a
query string or a fragment is always rejected.
use jev_client::BaseUrl;
assert_eq!(BaseUrl::default().as_str(), "https://api.typesafe.ai/");
assert!(BaseUrl::parse("http://127.0.0.1:8080").is_ok());
assert!(BaseUrl::parse("http://example.com").is_err());Implementations§
Source§impl BaseUrl
impl BaseUrl
Sourcepub fn parse(input: &str) -> Result<Self, InvalidBaseUrl>
pub fn parse(input: &str) -> Result<Self, InvalidBaseUrl>
Parses a base URL, requiring https:// for anything that is not a loopback address.
§Errors
See InvalidBaseUrl. The error never echoes the input, which could hold credentials.
Sourcepub fn parse_allowing_insecure_http(input: &str) -> Result<Self, InvalidBaseUrl>
pub fn parse_allowing_insecure_http(input: &str) -> Result<Self, InvalidBaseUrl>
Parses a base URL, also accepting plain http:// to a host that is not loopback.
The API key then crosses the network unencrypted. This exists for unusual test setups;
a caller that uses it should warn, as BaseUrl::sends_key_in_clear allows.
§Errors
See InvalidBaseUrl.
Sourcepub const fn sends_key_in_clear(&self) -> bool
pub const fn sends_key_in_clear(&self) -> bool
Returns true when requests travel over plain http:// to a host that is not loopback,
which only BaseUrl::parse_allowing_insecure_http permits.
Trait Implementations§
impl Eq for BaseUrl
impl StructuralPartialEq for BaseUrl
Auto Trait Implementations§
impl Forget for BaseUrl
impl Freeze for BaseUrl
impl Move for BaseUrl
impl RefUnwindSafe for BaseUrl
impl Send for BaseUrl
impl Sync for BaseUrl
impl Unpin for BaseUrl
impl UnsafeUnpin for BaseUrl
impl UnwindSafe for BaseUrl
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.