steam-user 0.2.7

Steam User web client for Rust - HTTP-based Steam Community interactions
Documentation
#[cfg(feature = "gas")]
use crate::gas::GasSteamUser;
#[cfg(feature = "remote")]
use crate::remote::RemoteSteamUser;
use crate::{
    action::{ActionContext, ApiAction},
    client::SteamUser,
    error::SteamUserError,
    steam_user_api::SteamUserApi,
};

/// A composite client that attempts requests across local, remote, and GAS
/// clients sequentially.
///
/// Note: To keep things simple and unified across error types, the
/// `SteamUserApi` implementation for `FallbackSteamUser` returns
/// `SteamUserError`. If `remote` or `gas` fail, their errors are mapped to a
/// `SteamUserError::Other`.
pub struct FallbackSteamUser {
    pub local: SteamUser,
    #[cfg(feature = "remote")]
    pub remote: Option<RemoteSteamUser>,
    #[cfg(feature = "gas")]
    pub gas: Option<GasSteamUser>,
}

impl FallbackSteamUser {
    pub fn new(local: SteamUser) -> Self {
        Self {
            local,
            #[cfg(feature = "remote")]
            remote: None,
            #[cfg(feature = "gas")]
            gas: None,
        }
    }

    #[cfg(feature = "remote")]
    pub fn with_remote(mut self, remote: RemoteSteamUser) -> Self {
        self.remote = Some(remote);
        self
    }

    #[cfg(feature = "gas")]
    pub fn with_gas(mut self, gas: GasSteamUser) -> Self {
        self.gas = Some(gas);
        self
    }
}

// The `impl SteamUserApi for FallbackSteamUser` is generated from the canonical
// method table in `crate::api_registry` via the `gen_fallback_impl!` callback.
for_each_api_method!(gen_fallback_impl);