Struct RibbitClient

Source
pub struct RibbitClient { /* private fields */ }
Expand description

Ribbit TCP client for querying Blizzard version services

The client supports multiple regions and both V1 (MIME) and V2 (raw PSV) protocols. It also supports automatic retries with exponential backoff for transient network errors.

§Example

use ribbit_client::{RibbitClient, Region, ProtocolVersion, Endpoint};

// Create a client for EU region with V2 protocol
let client = RibbitClient::new(Region::EU)
    .with_protocol_version(ProtocolVersion::V2)
    .with_max_retries(3);

// Request version information
let endpoint = Endpoint::ProductVersions("wow".to_string());
let response = client.request(&endpoint).await?;

Implementations§

Source§

impl RibbitClient

Source

pub fn new(region: Region) -> Self

Create a new Ribbit client with the specified region

Source

pub fn with_protocol_version(self, version: ProtocolVersion) -> Self

Set the protocol version to use

Source

pub fn with_max_retries(self, max_retries: u32) -> Self

Set the maximum number of retries for failed requests

Default is 0 (no retries) to maintain backward compatibility. Only network and connection errors are retried, not parsing errors.

Source

pub fn with_initial_backoff_ms(self, initial_backoff_ms: u64) -> Self

Set the initial backoff duration in milliseconds

Default is 100ms. This is the base delay before the first retry.

Source

pub fn with_max_backoff_ms(self, max_backoff_ms: u64) -> Self

Set the maximum backoff duration in milliseconds

Default is 10,000ms (10 seconds). Backoff will not exceed this value.

Source

pub fn with_backoff_multiplier(self, backoff_multiplier: f64) -> Self

Set the backoff multiplier

Default is 2.0. The backoff duration is multiplied by this value after each retry.

Source

pub fn with_jitter_factor(self, jitter_factor: f64) -> Self

Set the jitter factor (0.0 to 1.0)

Default is 0.1 (10% jitter). Adds randomness to prevent thundering herd.

Source

pub fn with_dns_cache_ttl(self, ttl: Duration) -> Self

Set the DNS cache TTL

Default is 300 seconds (5 minutes).

Source

pub fn region(&self) -> Region

Get the current region

Source

pub fn set_region(&mut self, region: Region)

Set the region

Source

pub fn protocol_version(&self) -> ProtocolVersion

Get the current protocol version

Source

pub fn set_protocol_version(&mut self, version: ProtocolVersion)

Set the protocol version

Source

pub async fn request_raw(&self, endpoint: &Endpoint) -> Result<Vec<u8>>

Send a request to the Ribbit service and get the raw response

This method supports automatic retries with exponential backoff for transient network errors. Parsing errors are not retried.

§Example
let client = RibbitClient::new(Region::US)
    .with_max_retries(3);
let raw_data = client.request_raw(&Endpoint::Summary).await?;
println!("Received {} bytes", raw_data.len());
§Errors

Returns an error if:

  • The connection to the Ribbit server fails after all retries
  • Sending the request fails
  • Receiving the response fails
  • The response is invalid or incomplete
Source

pub async fn request(&self, endpoint: &Endpoint) -> Result<Response>

Send a request to the Ribbit service and parse the response

§Errors

Returns an error if:

  • The raw request fails (see request_raw)
  • Parsing the response fails
  • V1 responses fail checksum validation
  • V1 responses have invalid MIME structure
Source

pub async fn request_typed<T: TypedResponse>( &self, endpoint: &Endpoint, ) -> Result<T>

Request with automatic type parsing

This method automatically parses the response into the appropriate typed structure based on the type parameter.

§Example
let client = RibbitClient::new(Region::US);
let versions: ProductVersionsResponse = client
    .request_typed(&Endpoint::ProductVersions("wow".to_string()))
    .await?;

for entry in &versions.entries {
    println!("{}: {} (build {})", entry.region, entry.versions_name, entry.build_id);
}
§Errors

Returns an error if:

  • The request fails
  • The response cannot be parsed as BPSV
  • The BPSV data doesn’t match the expected schema
Source

pub async fn get_product_versions( &self, product: &str, ) -> Result<ProductVersionsResponse>

Request product versions with typed response

Convenience method for requesting product version information.

§Example
let client = RibbitClient::new(Region::US);
let versions = client.get_product_versions("wow").await?;

if let Some(us_version) = versions.get_region("us") {
    println!("US version: {}", us_version.versions_name);
}
§Errors

Returns an error if:

  • The request fails
  • The response cannot be parsed as BPSV
  • The BPSV data doesn’t match the expected schema
Source

pub async fn get_product_cdns( &self, product: &str, ) -> Result<ProductCdnsResponse>

Request product CDNs with typed response

Convenience method for requesting CDN server information.

§Errors

Returns an error if:

  • The request fails
  • The response cannot be parsed as BPSV
  • The BPSV data doesn’t match the expected schema
Source

pub async fn get_product_bgdl( &self, product: &str, ) -> Result<ProductBgdlResponse>

Request product background download config with typed response

Convenience method for requesting background download configuration.

§Errors

Returns an error if:

  • The request fails
  • The response cannot be parsed as BPSV
  • The BPSV data doesn’t match the expected schema
Source

pub async fn get_summary(&self) -> Result<SummaryResponse>

Request summary of all products with typed response

Convenience method for requesting the summary of all available products.

§Example
let client = RibbitClient::new(Region::US);
let summary = client.get_summary().await?;

for product in &summary.products {
    println!("{}: seqn {}", product.product, product.seqn);
}
§Errors

Returns an error if:

  • The request fails
  • The response cannot be parsed as BPSV
  • The BPSV data doesn’t match the expected schema

Trait Implementations§

Source§

impl Clone for RibbitClient

Source§

fn clone(&self) -> RibbitClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for RibbitClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more