pub struct ApiClient { /* private fields */ }
Expand description

Api client for demos.tf

Example

use demostf_client::{ListOrder, ListParams, ApiClient};

let client = ApiClient::new();

let demos = client.list(ListParams::default().with_order(ListOrder::Ascending), 1).await?;

for demo in demos {
    println!("{}: {}", demo.id, demo.name);
}

Implementations

Create an api client for the default demos.tf endpoint

Create an api client using a different api endpoint

Errors

Returns an error when the provided base_url is not a valid url

Create an api client using a different api endpoint and timeout

Errors

Returns an error when the provided base_url is not a valid url

List demos with the provided options

note that the pages start counting at 1

Example
use demostf_client::{ListOrder, ListParams};

let demos = client.list(ListParams::default().with_order(ListOrder::Ascending), 1).await?;

for demo in demos {
    println!("{}: {}", demo.id, demo.name);
}

List demos uploaded by a user with the provided options

note that the pages start counting at 1

Example
use demostf_client::{ListOrder, ListParams};

let client = ApiClient::default();
let demos = client.list_uploads(SteamID::from(76561198024494988), ListParams::default().with_order(ListOrder::Ascending), 1).await?;

for demo in demos {
    println!("{}: {}", demo.id, demo.name);
}

Get the data for a single demo

Example
let demo = client.get(9).await?;

println!("{}: {}", demo.id, demo.name);
println!("players:");

for player in demo.players.unwrap_or_default() {
    println!("{}", player.user.name);
}

Get user info by id

Example
let user = client.get_user(1).await?;

println!("{} ({})", user.name, user.steam_id.steam3());

Search for players by name

Example
let client = ApiClient::default();
let users = client.search_users("icewind").await?;

for user in users {
  println!("{} ({})", user.name, user.steam_id.steam3());
}

List demos with the provided options

Example
let chat = client.get_chat(447678).await?;

for message in chat {
    println!("{}: {}", message.user, message.message);
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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