tapo 0.9.0

Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with light bulbs (L510, L520, L530, L535, L610, L630), light strips (L900, L920, L930), plugs (P100, P105, P110, P110M, P115), power strips (P300, P304M, P306, P316M), hubs (H100), switches (S200B, S200D, S210) and sensors (KE100, T100, T110, T300, T310, T315).
Documentation
use base64::{Engine as _, engine::general_purpose};

use crate::error::Error;

/// Implemented by all Device Info Result variations.
pub(crate) trait DecodableResultExt
where
    Self: Sized,
{
    /// Decodes a base64 encoded string from the result.
    fn decode(self) -> Result<Self, Error>;
}

impl DecodableResultExt for serde_json::Value {
    fn decode(self) -> Result<Self, Error> {
        Ok(self)
    }
}

pub(crate) fn decode_value(value: &str) -> anyhow::Result<String> {
    let decoded_bytes = general_purpose::STANDARD.decode(value)?;
    Ok(std::str::from_utf8(&decoded_bytes)?.to_string())
}