#[non_exhaustive]pub struct GatewayEndpoint { /* private fields */ }Expand description
A validated base URL for the gateway’s OpenAI-compatible API (its /v1
root).
Construction requires an http or https scheme and a host, so a
client always points at a usable endpoint. Any trailing slash is removed
so request paths join cleanly.
Implementations§
Source§impl GatewayEndpoint
impl GatewayEndpoint
Sourcepub fn new(url: &str) -> Result<GatewayEndpoint, GatewayConfigError>
pub fn new(url: &str) -> Result<GatewayEndpoint, GatewayConfigError>
Validates and normalizes a gateway base URL.
The URL is checked with a strict URL parser.
§Errors
Returns a GatewayConfigError when url fails to parse as an
absolute URL, uses a scheme other than http or https, omits the
host, embeds credentials (a user:pass@ component), or has a query or
fragment.
A query or fragment is rejected because an API root is a bare path.
No error includes url, because a URL can contain a credential.
Sourcepub fn is_loopback(&self) -> bool
pub fn is_loopback(&self) -> bool
Returns whether the endpoint’s host is the local machine.
It returns true for localhost, for 127.0.0.1 and the rest of
127.0.0.0/8, and for ::1. It returns false for every other name
or address. By default, a gateway on the local machine accepts callers
that omit the key, so
GatewayChat::from_env makes the
bearer key optional exactly when this returns true.
Trait Implementations§
Source§impl Clone for GatewayEndpoint
impl Clone for GatewayEndpoint
Source§fn clone(&self) -> GatewayEndpoint
fn clone(&self) -> GatewayEndpoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GatewayEndpoint
impl Debug for GatewayEndpoint
impl Eq for GatewayEndpoint
Source§impl PartialEq for GatewayEndpoint
impl PartialEq for GatewayEndpoint
impl StructuralPartialEq for GatewayEndpoint
Source§impl TryFrom<&str> for GatewayEndpoint
impl TryFrom<&str> for GatewayEndpoint
Source§type Error = GatewayConfigError
type Error = GatewayConfigError
Source§fn try_from(url: &str) -> Result<GatewayEndpoint, GatewayConfigError>
fn try_from(url: &str) -> Result<GatewayEndpoint, GatewayConfigError>
Auto Trait Implementations§
impl Freeze for GatewayEndpoint
impl RefUnwindSafe for GatewayEndpoint
impl Send for GatewayEndpoint
impl Sync for GatewayEndpoint
impl Unpin for GatewayEndpoint
impl UnsafeUnpin for GatewayEndpoint
impl UnwindSafe for GatewayEndpoint
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more