rust-wechat-core 0.1.3

wechat api core
Documentation
//! 核心公共模块
//! 包含API请求封装、认证鉴权、错误处理等公共功能

pub mod client;
pub mod error;
pub mod utils;
pub use error::*;

#[macro_export]
#[doc(hidden)]
macro_rules! __setter {
    ($field:ident: Option<$ty:ty>) => {
        #[inline(always)]
        pub fn $field<T: Into<$ty>>(mut self, value: T) -> Self {
            self.$field = Some(value.into());
            self
        }
    };
    (children: Vec<$ty:ty>) => {
        #[inline(always)]
        pub fn add_child<T: Into<$ty>>(mut self, value: T) -> Self {
            self.children.push(value.into());
            self
        }
        #[inline(always)]
        pub fn children<T: Into<Vec<$ty>>>(mut self, value: T) -> Self {
            self.children = value.into();
            self
        }
    };
    ($field:ident: $ty:ty) => {
        #[inline(always)]
        pub fn $field<T: Into<$ty>>(mut self, value: T) -> Self {
            self.$field = value.into();
            self
        }
    };
}


#[macro_export]
#[doc(hidden)]
macro_rules! __string_enum {
    ($name:ident { $($variant:ident = $value:literal $(| $value2:literal)*, )* }) => {
        impl std::fmt::Display for $name {
            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
                match *self {
                    $( $name::$variant => write!(f, $value), )*
                }
            }
        }

        impl std::str::FromStr for $name {
            type Err = String;

            fn from_str(s: &str) -> Result<Self, Self::Err> {
                match s {
                    $($value $(| $value2)* => Ok($name::$variant),)*
                    s => Err(format!(
                        "Unkown Value. Found `{}`, Expected `{}`",
                        s,
                        stringify!($($value,)*)
                    ))
                }
            }
        }
    }
}

pub type Result<T> = std::result::Result<T, WechatError>;