pub struct DDApi { /* private fields */ }Implementations§
Source§impl DDApi
impl DDApi
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new DDApi instance with default settings
§Examples
use ddapi_rs::prelude::*;
let api = DDApi::new();Sourcepub fn new_with_client(client: Client) -> Self
pub fn new_with_client(client: Client) -> Self
Creates a new DDApi instance with a custom HTTP client
This allows you to configure your own client with custom timeouts, headers, or other settings.
§Arguments
client- A pre-configuredreqwest::Clientinstance
§Examples
use ddapi_rs::prelude::*;
use reqwest::Client;
let client = Client::builder()
.timeout(std::time::Duration::from_secs(10))
.build()
.unwrap();
let api = DDApi::new_with_client(client);Sourcepub async fn _generator<T>(&self, url: &str) -> Result<T>
pub async fn _generator<T>(&self, url: &str) -> Result<T>
Executes an API request and deserializes the JSON response
This method handles API requests and automatically deserializes the JSON response
into the specified type. The caching behavior is determined by the cache feature flag.
§Type Parameters
T- The type to deserialize the response into. Must implementDeserializeOwned + Send + Sync + 'static
§Arguments
url- The API endpoint URL to request
§Returns
§Returns
Result<T> containing the deserialized data on success, or an error on failure
Sourcepub async fn _generator_no_cache<T>(&self, url: &str) -> Result<T>where
T: DeserializeOwned,
pub async fn _generator_no_cache<T>(&self, url: &str) -> Result<T>where
T: DeserializeOwned,
Trait Implementations§
Source§impl DDnetApi for DDApi
impl DDnetApi for DDApi
Source§async fn custom_master(&self, master: MasterServer) -> Result<Master>
async fn custom_master(&self, master: MasterServer) -> Result<Master>
Fetches server list from a specific master server
Allows selecting which master server to query. DDNet has multiple master servers for redundancy and load distribution.
§Arguments
master- The master server to query (MasterServer::One,MasterServer::Two, etc.)
§Examples
ⓘ
use ddapi_rs::prelude::*;
use ddapi_rs::prelude::ddnet::*;
let api = DDApi::new();
// Use secondary master server as fallback
let master = api.custom_master(MasterServer::Two).await?;Source§async fn query_mapper(&self, player: &str) -> Result<Vec<QueryMapper>>
async fn query_mapper(&self, player: &str) -> Result<Vec<QueryMapper>>
Source§async fn releases_map(&self) -> Result<Vec<ReleasesMaps>>
async fn releases_map(&self) -> Result<Vec<ReleasesMaps>>
Auto Trait Implementations§
impl Freeze for DDApi
impl !RefUnwindSafe for DDApi
impl Send for DDApi
impl Sync for DDApi
impl Unpin for DDApi
impl !UnwindSafe for DDApi
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
Mutably borrows from an owned value. Read more