Struct BBApi

Source
pub struct BBApi(/* private fields */);
Expand description

BattleBit API Struct

Implementations§

Source§

impl BBApi

Source

pub fn new() -> BBApi

Shorthand for BBApi::Default()
Creates a new BBApi with the default URL

Examples found in repository?
examples/serverlist.rs (line 4)
3fn main() {
4    let api = BBApi::new();
5    let server_list = api.server_list()
6        .expect("Retrieving server list");
7
8    server_list.into_iter().for_each(|server| {
9        println!("{} [{}, {}, {}] ({}, {}, {})", 
10            server.name(), 
11            server.gamemode(), 
12            server.map(),
13            server.map_size(),
14            server.hz(), 
15            server.anti_cheat(),
16            server.build()
17        )
18    });
19}
More examples
Hide additional examples
examples/top_leaderboard.rs (line 29)
28fn main() {
29    let api = BBApi::new();
30    let lb = api.leaderboard()
31        .expect("Retrieving leaderboard");
32
33    print_clan(lb.top_clans());
34
35    print_player(lb.most_kills(), "Most kills", "Kills");
36    print_player(lb.most_roadkills(), "Most roadkills", "Roadkills");
37    print_player(lb.longest_kills(), "Longest kill", "Meters");
38
39    print_player(lb.most_xp(), "Most XP", "XP");
40    print_player(lb.most_heals(), "Most heal", "HP");
41    print_player(lb.most_revives(), "Most revives", "Revives");
42
43    print_player(lb.most_objectives_complete(), "Most objectives", "Objectives");
44
45    print_player(lb.most_vehicles_destroyed(), "Vehicles destroyed", "Vehicles");
46    print_player(lb.most_vehicle_repairs(), "Vehicle repairs", "Repairs");
47}
examples/serverlist_unknown.rs (line 4)
3fn main() {
4    let api = BBApi::new();
5
6    let server_list = api.server_list()
7        .expect("Retrieving server list");
8
9    let servers_with_unknown: Vec<battlebit_api::ServerData> = server_list
10        .into_iter()
11        .filter(|server| server.has_unknown())
12        .collect();
13
14    if servers_with_unknown.is_empty() {
15        println!("No servers with unknown fields found!")
16    } else {
17        servers_with_unknown.iter().for_each(|server| {
18            println!("{} [{}, {}, {}] ({}, {}, {})", 
19                server.name(), 
20                server.gamemode(), 
21                server.map(),
22                server.map_size(),
23                server.hz(), 
24                server.anti_cheat(),
25                server.build()
26            )
27        });
28    }
29}
Source

pub fn with_url(url: Url) -> BBApi

Creates a new BBApi with the given URL

Source

pub fn server_list(&self) -> Result<Vec<ServerData>, Error>

Fetches the server list and puts it into a Vec<ServerData>

Examples found in repository?
examples/serverlist.rs (line 5)
3fn main() {
4    let api = BBApi::new();
5    let server_list = api.server_list()
6        .expect("Retrieving server list");
7
8    server_list.into_iter().for_each(|server| {
9        println!("{} [{}, {}, {}] ({}, {}, {})", 
10            server.name(), 
11            server.gamemode(), 
12            server.map(),
13            server.map_size(),
14            server.hz(), 
15            server.anti_cheat(),
16            server.build()
17        )
18    });
19}
More examples
Hide additional examples
examples/serverlist_unknown.rs (line 6)
3fn main() {
4    let api = BBApi::new();
5
6    let server_list = api.server_list()
7        .expect("Retrieving server list");
8
9    let servers_with_unknown: Vec<battlebit_api::ServerData> = server_list
10        .into_iter()
11        .filter(|server| server.has_unknown())
12        .collect();
13
14    if servers_with_unknown.is_empty() {
15        println!("No servers with unknown fields found!")
16    } else {
17        servers_with_unknown.iter().for_each(|server| {
18            println!("{} [{}, {}, {}] ({}, {}, {})", 
19                server.name(), 
20                server.gamemode(), 
21                server.map(),
22                server.map_size(),
23                server.hz(), 
24                server.anti_cheat(),
25                server.build()
26            )
27        });
28    }
29}
Source

pub fn leaderboard(&self) -> Result<Leaderboard, Error>

Fetches the leaderboard.

Examples found in repository?
examples/top_leaderboard.rs (line 30)
28fn main() {
29    let api = BBApi::new();
30    let lb = api.leaderboard()
31        .expect("Retrieving leaderboard");
32
33    print_clan(lb.top_clans());
34
35    print_player(lb.most_kills(), "Most kills", "Kills");
36    print_player(lb.most_roadkills(), "Most roadkills", "Roadkills");
37    print_player(lb.longest_kills(), "Longest kill", "Meters");
38
39    print_player(lb.most_xp(), "Most XP", "XP");
40    print_player(lb.most_heals(), "Most heal", "HP");
41    print_player(lb.most_revives(), "Most revives", "Revives");
42
43    print_player(lb.most_objectives_complete(), "Most objectives", "Objectives");
44
45    print_player(lb.most_vehicles_destroyed(), "Vehicles destroyed", "Vehicles");
46    print_player(lb.most_vehicle_repairs(), "Vehicle repairs", "Repairs");
47}

Trait Implementations§

Source§

impl Clone for BBApi

Source§

fn clone(&self) -> BBApi

Returns a copy 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 Debug for BBApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BBApi

Source§

fn default() -> Self

Creates a new BBApi with the default URL
Default URL is https://publicapi.battlebit.cloud/

Source§

impl PartialEq for BBApi

Source§

fn eq(&self, other: &BBApi) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for BBApi

Auto Trait Implementations§

§

impl Freeze for BBApi

§

impl RefUnwindSafe for BBApi

§

impl Send for BBApi

§

impl Sync for BBApi

§

impl Unpin for BBApi

§

impl UnwindSafe for BBApi

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> 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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T