[][src]Struct demostf_client::ApiClient

pub struct ApiClient { /* fields omitted */ }

Implementations

impl ApiClient[src]

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);
}

pub fn new() -> Self[src]

Create an api client for the default demos.tf endpoint

pub fn with_base_url(base_url: impl IntoUrl) -> Result<Self, Error>[src]

Create an api client using a different api endpoint

pub async fn list<'_>(
    &'_ self,
    params: ListParams,
    page: u32
) -> Result<Vec<Demo>, Error>
[src]

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);
}

pub async fn get<'_>(&'_ self, demo_id: u32) -> Result<Demo, Error>[src]

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 {
    println!("{}", player.user.name);
}

pub async fn get_user<'_>(&'_ self, user_id: u32) -> Result<User, Error>[src]

Get user info by id

Example

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

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

pub async fn get_chat<'_>(
    &'_ self,
    demo_id: u32
) -> Result<Vec<ChatMessage>, Error>
[src]

List demos with the provided options

Example

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

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

pub async fn set_url<'_, '_, '_, '_, '_>(
    &'_ self,
    demo_id: u32,
    backend: &'_ str,
    path: &'_ str,
    url: &'_ str,
    hash: [u8; 16],
    key: &'_ str
) -> Result<(), Error>
[src]

Trait Implementations

impl Clone for ApiClient[src]

impl Default for ApiClient[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.