Skip to main content

steam_client/services/
store.rs

1//! Store service functionality.
2//!
3//! This module handles interactions with the Steam Store, such as retrieving
4//! tag information and store item details.
5
6use crate::{error::SteamError, SteamClient};
7
8/// Store tag information.
9#[derive(Debug, Clone)]
10pub struct StoreTag {
11    /// The tag ID.
12    pub tagid: u32,
13    /// English name of the tag.
14    pub english_name: Option<String>,
15    /// Localized name of the tag.
16    pub name: Option<String>,
17    /// Normalized name.
18    pub normalized_name: Option<String>,
19}
20
21impl SteamClient {
22    /// Get localized names for store tags.
23    ///
24    /// # Arguments
25    /// * `language` - The language to get names for (e.g., "english").
26    /// * `tag_ids` - The tag IDs to request.
27    ///
28    /// # Returns
29    ///
30    /// Returns a list of store tags with localized names.
31    pub async fn get_store_tag_names(&mut self, language: &str, tag_ids: &[u32]) -> Result<Vec<StoreTag>, SteamError> {
32        if !self.is_logged_in() {
33            return Err(SteamError::NotLoggedOn);
34        }
35
36        let request = steam_protos::CStoreGetLocalizedNameForTagsRequest { language: Some(language.to_string()), tagids: tag_ids.to_vec() };
37
38        let response: steam_protos::CStoreGetLocalizedNameForTagsResponse = self.send_unified_request_and_wait("Store.GetLocalizedNameForTags#1", &request).await?;
39
40        let mut tags = Vec::new();
41        for tag in response.tags {
42            tags.push(StoreTag {
43                tagid: tag.tagid.unwrap_or(0),
44                english_name: tag.english_name,
45                name: tag.name,
46                normalized_name: tag.normalized_name,
47            });
48        }
49
50        Ok(tags)
51    }
52}