pub struct Endpoint { /* private fields */ }Expand description
Complete API endpoint configuration combining host tier and API version
The Endpoint type provides an ergonomic way to configure both the API host
tier (Public/Enterprise) and version (V2/V3) together.
§Examples
§Using convenience constructors (recommended)
use odos_sdk::{ClientConfig, Endpoint};
// Public API V2 (default, recommended for production)
let config = ClientConfig {
endpoint: Endpoint::public_v2(),
..Default::default()
};
// Enterprise API V3 (latest features)
let config = ClientConfig {
endpoint: Endpoint::enterprise_v3(),
..Default::default()
};§Using explicit construction
use odos_sdk::{Endpoint, ApiHost, ApiVersion};
let endpoint = Endpoint::new(ApiHost::Enterprise, ApiVersion::V2);
assert_eq!(endpoint.quote_url().as_str(), "https://enterprise-api.odos.xyz/sor/quote/v2");§Migration from old API
use odos_sdk::{ClientConfig, Endpoint};
// Old way (still works but deprecated)
// let config = ClientConfig {
// endpoint: EndpointBase::Public,
// endpoint_version: EndpointVersion::V2,
// ..Default::default()
// };
// New way
let config = ClientConfig {
endpoint: Endpoint::public_v2(),
..Default::default()
};Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub const fn new(host: ApiHost, version: ApiVersion) -> Self
pub const fn new(host: ApiHost, version: ApiVersion) -> Self
Create a new endpoint with specific host and version
§Examples
use odos_sdk::{Endpoint, ApiHost, ApiVersion};
let endpoint = Endpoint::new(ApiHost::Public, ApiVersion::V2);Sourcepub const fn public_v2() -> Self
pub const fn public_v2() -> Self
Public API V2 endpoint (default, recommended for production)
This is the recommended configuration for most production use cases.
§Examples
use odos_sdk::Endpoint;
let endpoint = Endpoint::public_v2();
assert_eq!(endpoint.quote_url().as_str(), "https://api.odos.xyz/sor/quote/v2");Sourcepub const fn public_v3() -> Self
pub const fn public_v3() -> Self
Public API V3 endpoint
Use for latest features and optimizations on the public API.
§Examples
use odos_sdk::Endpoint;
let endpoint = Endpoint::public_v3();
assert_eq!(endpoint.quote_url().as_str(), "https://api.odos.xyz/sor/quote/v3");Sourcepub const fn enterprise_v2() -> Self
pub const fn enterprise_v2() -> Self
Enterprise API V2 endpoint
Use for enterprise tier with V2 API. Requires an API key.
§Examples
use odos_sdk::Endpoint;
let endpoint = Endpoint::enterprise_v2();
assert_eq!(endpoint.quote_url().as_str(), "https://enterprise-api.odos.xyz/sor/quote/v2");Sourcepub const fn enterprise_v3() -> Self
pub const fn enterprise_v3() -> Self
Enterprise API V3 endpoint
Use for enterprise tier with latest V3 features. Requires an API key.
§Examples
use odos_sdk::Endpoint;
let endpoint = Endpoint::enterprise_v3();
assert_eq!(endpoint.quote_url().as_str(), "https://enterprise-api.odos.xyz/sor/quote/v3");Sourcepub fn quote_url(&self) -> Url
pub fn quote_url(&self) -> Url
Get the quote URL for this endpoint
Constructs the full URL for the quote endpoint by combining the base URL with the appropriate version path.
§Examples
use odos_sdk::Endpoint;
let endpoint = Endpoint::public_v2();
assert_eq!(endpoint.quote_url().as_str(), "https://api.odos.xyz/sor/quote/v2");
let endpoint = Endpoint::enterprise_v3();
assert_eq!(endpoint.quote_url().as_str(), "https://enterprise-api.odos.xyz/sor/quote/v3");Sourcepub fn assemble_url(&self) -> Url
pub fn assemble_url(&self) -> Url
Get the assemble URL for this endpoint
The assemble endpoint is version-independent and constructs transaction data from a previously obtained quote path ID.
§Examples
use odos_sdk::Endpoint;
let endpoint = Endpoint::public_v2();
assert_eq!(endpoint.assemble_url().as_str(), "https://api.odos.xyz/sor/assemble");Sourcepub const fn host(&self) -> ApiHost
pub const fn host(&self) -> ApiHost
Get the API host tier
§Examples
use odos_sdk::{Endpoint, ApiHost};
let endpoint = Endpoint::public_v2();
assert_eq!(endpoint.host(), ApiHost::Public);Sourcepub const fn version(&self) -> ApiVersion
pub const fn version(&self) -> ApiVersion
Get the API version
§Examples
use odos_sdk::{Endpoint, ApiVersion};
let endpoint = Endpoint::public_v2();
assert_eq!(endpoint.version(), ApiVersion::V2);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Endpoint
impl<'de> Deserialize<'de> for Endpoint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy for Endpoint
impl Eq for Endpoint
impl StructuralPartialEq for Endpoint
Auto Trait Implementations§
impl Freeze for Endpoint
impl RefUnwindSafe for Endpoint
impl Send for Endpoint
impl Sync for Endpoint
impl Unpin for Endpoint
impl UnwindSafe for Endpoint
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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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