2 releases
0.1.1 | Apr 2, 2021 |
---|---|
0.1.0 | Apr 1, 2021 |
#1418 in Text processing
96KB
2.5K
SLoC
Destiny-rs
A library for interacting with Bungie's destiny 2 api, and manifest
A simple example that looks up someone's characters with their bungie.net id, and queries the manifest multiple times:
use destiny_rs::models::{api::DestinyAPI, locale::Locale, membership::MembershipType, manifest::ManifestKey, manifest_models};
use destiny_rs::traits::id::DestinyMembershipID;
use tokio;
use std::env;
use std::path::PathBuf;
#[tokio::main]
pub async fn main() {
let api = DestinyAPI::new(&env::var("API_KEY").unwrap());
let mut manifest_path = PathBuf::new();
manifest_path.push("./manifest");
let manifest = api.manifest(manifest_path, Locale::English).await.unwrap();
let user = api.get_user_membership_data_by_membershipid_bng(&19377351, &MembershipType::Steam).await.unwrap();
let characters = user.get_characters(&api, &MembershipType::Steam).await.unwrap();
println!("{}'s characters:", user.bungie_net_user.display_name);
for character in characters {
// these don't do any api calls, they just query the downloaded manifest
let race: manifest_models::Race = manifest.query(character.race_hash, ManifestKey::Race).unwrap();
let gender: manifest_models::Gender = manifest.query(character.gender_hash, ManifestKey::Gender).unwrap();
let class: manifest_models::Class = manifest.query(character.class_hash, ManifestKey::Class).unwrap();
println!(
"{} {} {} is power level {}",
gender.display_properties.name,
race.display_properties.name,
class.display_properties.name,
character.stats.power,
);
}
}
Dependencies
~9–22MB
~311K SLoC