pub struct SubscriptionClient { /* private fields */ }Expand description
Public client for the separate 3x-ui subscription HTTP/HTTPS server.
This client intentionally has no panel authentication or cookie state. The subscription identifier embedded into every request path is redacted from SDK errors.
Implementations§
Source§impl SubscriptionClient
impl SubscriptionClient
Sourcepub fn new(server_url: impl AsRef<str>) -> Result<Self>
pub fn new(server_url: impl AsRef<str>) -> Result<Self>
Creates a client using the default /sub/, /json/, and /clash/
paths below server_url.
§Errors
Returns an error when the URL or HTTP-client configuration is invalid.
Sourcepub fn builder(server_url: impl AsRef<str>) -> Result<SubscriptionClientBuilder>
pub fn builder(server_url: impl AsRef<str>) -> Result<SubscriptionClientBuilder>
Starts configuring a standalone subscription client.
§Errors
Returns an error when server_url is not an absolute HTTP(S) URL.
Sourcepub fn from_settings(settings: &SubscriptionSettings) -> Result<Self>
pub fn from_settings(settings: &SubscriptionSettings) -> Result<Self>
Creates a client from the absolute public URIs and fallback paths in a panel settings snapshot.
§Errors
Returns an error when subURI is not an absolute HTTP(S) prefix or any
configured URI/HTTP option is invalid.
Sourcepub const fn response_body_limit(&self) -> usize
pub const fn response_body_limit(&self) -> usize
Returns the configured maximum subscription response body size.
Sourcepub async fn raw(
&self,
subscription_id: &str,
) -> Result<SubscriptionResponse<SubscriptionDocument>>
pub async fn raw( &self, subscription_id: &str, ) -> Result<SubscriptionResponse<SubscriptionDocument>>
Fetches the raw subscription body.
The body is base64 when the panel’s subEncrypt setting is enabled.
§Errors
Returns an error for transport or unsuccessful HTTP status.
Sourcepub async fn html(
&self,
subscription_id: &str,
) -> Result<SubscriptionResponse<SubscriptionDocument>>
pub async fn html( &self, subscription_id: &str, ) -> Result<SubscriptionResponse<SubscriptionDocument>>
Fetches the browser HTML information page.
§Errors
Returns an error for transport, unsuccessful HTTP status, or invalid UTF-8.
Sourcepub async fn info(&self, subscription_id: &str) -> Result<SubscriptionInfo>
pub async fn info(&self, subscription_id: &str) -> Result<SubscriptionInfo>
Fetches the typed format=info status view without imported link data.
§Errors
Returns an error for transport, unsuccessful HTTP status, or invalid JSON.
Sourcepub async fn info_with_metadata(
&self,
subscription_id: &str,
) -> Result<SubscriptionResponse<SubscriptionInfo>>
pub async fn info_with_metadata( &self, subscription_id: &str, ) -> Result<SubscriptionResponse<SubscriptionInfo>>
Fetches the typed information view together with common and HWID headers.
Prefer this method when device-limit state is relevant to the caller.
§Errors
Returns an error for transport, unsuccessful HTTP status, or invalid JSON.
Sourcepub async fn json(
&self,
subscription_id: &str,
) -> Result<SubscriptionResponse<SubscriptionJson>>
pub async fn json( &self, subscription_id: &str, ) -> Result<SubscriptionResponse<SubscriptionJson>>
Fetches and parses the Xray JSON subscription document.
The raw-download view is requested to avoid browser content negotiation.
§Errors
Returns an error for transport, unsuccessful HTTP status, or invalid JSON.
Sourcepub async fn clash(
&self,
subscription_id: &str,
) -> Result<SubscriptionResponse<SubscriptionDocument>>
pub async fn clash( &self, subscription_id: &str, ) -> Result<SubscriptionResponse<SubscriptionDocument>>
Fetches the Clash/Mihomo YAML subscription document.
The raw-download view is requested to avoid browser content negotiation.
§Errors
Returns an error for transport, unsuccessful HTTP status, or invalid UTF-8.
Sourcepub async fn mihomo(
&self,
subscription_id: &str,
) -> Result<SubscriptionResponse<SubscriptionDocument>>
pub async fn mihomo( &self, subscription_id: &str, ) -> Result<SubscriptionResponse<SubscriptionDocument>>
Fetches the Mihomo alias (/mihomo/), when enabled and not shadowed by a configured path.
§Errors
Returns a configuration error when the alias is shadowed, or an error for transport, unsuccessful HTTP status, or invalid UTF-8.
Sourcepub async fn mihomo_metadata(
&self,
subscription_id: &str,
) -> Result<SubscriptionMetadata>
pub async fn mihomo_metadata( &self, subscription_id: &str, ) -> Result<SubscriptionMetadata>
Retrieves response headers from the mihomo alias.
§Errors
Returns a configuration error when the alias is shadowed, or an error for transport or unsuccessful HTTP status.
Sourcepub async fn clash_legacy(
&self,
subscription_id: &str,
) -> Result<SubscriptionResponse<SubscriptionDocument>>
pub async fn clash_legacy( &self, subscription_id: &str, ) -> Result<SubscriptionResponse<SubscriptionDocument>>
Fetches the legacy Clash alias (/clash-legacy/), when enabled and not shadowed by a configured path.
§Errors
Returns a configuration error when the alias is shadowed, or an error for transport, unsuccessful HTTP status, or invalid UTF-8.
Sourcepub async fn clash_legacy_metadata(
&self,
subscription_id: &str,
) -> Result<SubscriptionMetadata>
pub async fn clash_legacy_metadata( &self, subscription_id: &str, ) -> Result<SubscriptionMetadata>
Retrieves response headers from the clash_legacy alias.
§Errors
Returns a configuration error when the alias is shadowed, or an error for transport or unsuccessful HTTP status.
Sourcepub async fn hwid_status(&self, subscription_id: &str) -> Result<HwidSlotStatus>
pub async fn hwid_status(&self, subscription_id: &str) -> Result<HwidSlotStatus>
Reads device-slot counts without registering or touching a device.
§Errors
Returns an error for transport, unsuccessful HTTP status, or malformed JSON.
Sourcepub async fn hwid_status_metadata(
&self,
subscription_id: &str,
) -> Result<SubscriptionMetadata>
pub async fn hwid_status_metadata( &self, subscription_id: &str, ) -> Result<SubscriptionMetadata>
Checks the read-only HWID status route with HEAD.
§Errors
Returns an error for transport or unsuccessful HTTP status.
Sourcepub async fn raw_metadata(
&self,
subscription_id: &str,
) -> Result<SubscriptionMetadata>
pub async fn raw_metadata( &self, subscription_id: &str, ) -> Result<SubscriptionMetadata>
Executes HEAD against the raw subscription route.
§Errors
Returns an error for transport or unsuccessful HTTP status.
Sourcepub async fn json_metadata(
&self,
subscription_id: &str,
) -> Result<SubscriptionMetadata>
pub async fn json_metadata( &self, subscription_id: &str, ) -> Result<SubscriptionMetadata>
Executes HEAD against the JSON subscription route.
§Errors
Returns an error for transport or unsuccessful HTTP status.
Sourcepub async fn clash_metadata(
&self,
subscription_id: &str,
) -> Result<SubscriptionMetadata>
pub async fn clash_metadata( &self, subscription_id: &str, ) -> Result<SubscriptionMetadata>
Executes HEAD against the Clash subscription route.
§Errors
Returns an error for transport or unsuccessful HTTP status.
Trait Implementations§
Source§impl Clone for SubscriptionClient
impl Clone for SubscriptionClient
Auto Trait Implementations§
impl !RefUnwindSafe for SubscriptionClient
impl !UnwindSafe for SubscriptionClient
impl Freeze for SubscriptionClient
impl Send for SubscriptionClient
impl Sync for SubscriptionClient
impl Unpin for SubscriptionClient
impl UnsafeUnpin for SubscriptionClient
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<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