steam-user 0.2.9

Steam User web client for Rust - HTTP-based Steam Community interactions
Documentation
//! API action definitions and error context extensions.
//!
//! The `ApiAction` enum and its `is_read_only` classifier are generated from
//! the canonical method table in [`crate::api_registry`] via the
//! `define_api_action!` callback, so they can never drift out of sync with the
//! method list.

use crate::error::SteamUserError;

for_each_api_method!(define_api_action);

/// Extension trait to attach `ApiAction` context to errors.
pub trait ActionContext<T> {
    fn with_action(self, action: ApiAction) -> Result<T, SteamUserError>;
}

impl<T, E> ActionContext<T> for Result<T, E>
where
    SteamUserError: From<E>,
{
    fn with_action(self, action: ApiAction) -> Result<T, SteamUserError> {
        self.map_err(|e| SteamUserError::ActionFailed { action, source: Box::new(SteamUserError::from(e)) })
    }
}