Struct RobotClient

Source
pub struct RobotClient {
    pub key: String,
    pub client: Client,
}
Expand description

企业微信群机器人客户端

Fields§

§key: String§client: Client

Implementations§

Source§

impl RobotClient

Source

pub fn new(key: &str) -> Self

创建一个新的机器人客户端实例

§Arguments
  • webhook_key - 机器人的 Webhook Key (从 webhook_url 中提取,例如: 693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa)
Source

pub async fn send_message(&self, message: &RobotMessage) -> Result<()>

发送消息到群机器人

Source

pub async fn upload_media( &self, file_path: &str, file_type: FileType, ) -> Result<SendRobotMessage>

上传文件到企业微信,用于发送文件或语音消息 0

§Arguments
  • file_path - 本地文件的路径
  • file_type - 文件类型,根据企业微信文档,此处应为 “file” (文件), “voice” (语音), “image” (图片) 0
Source

pub async fn send_file_message(&self, file_path: &str) -> Result<()>

发送文件消息 (通过先上传文件获取media_id)

Trait Implementations§

Source§

impl ClientTrait for RobotClient

Source§

async fn access_token(&self) -> Result<String>

Source§

async fn refresh_access_token(&mut self) -> Result<()>

Source§

fn http_client(&self) -> &Client

Source§

fn url_with_query<I, K, V>( &self, url: &str, queries: I, ) -> Result<Url, WechatError>
where I: IntoIterator, <I as IntoIterator>::Item: Borrow<(K, V)>, K: AsRef<str>, V: AsRef<str>,

Source§

fn authorized_url( &self, url: &str, ) -> impl Future<Output = Result<Url, WechatError>> + Send
where Self: Sync,

Source§

fn get_empty<R, U>( &self, url: U, ) -> impl Future<Output = Result<R, WechatError>> + Send
where R: DeserializeOwned, U: IntoUrl + Send, Self: Sync,

Source§

fn get<R, U, T>( &self, url: U, query: &T, ) -> impl Future<Output = Result<R, WechatError>> + Send
where R: DeserializeOwned, U: IntoUrl + Send, T: Serialize + Sync + ?Sized, Self: Sync,

Source§

fn post_empty<R, U>( &self, url: U, ) -> impl Future<Output = Result<R, WechatError>> + Send
where R: DeserializeOwned, U: IntoUrl + Send, Self: Sync,

Source§

fn post<R, U, T>( &self, url: U, data: &T, ) -> impl Future<Output = Result<R, WechatError>> + Send
where R: DeserializeOwned, U: IntoUrl + Send, T: Serialize + Sync + ?Sized, Self: Sync,

Source§

fn upload<R, U>( &self, url: U, multipart: Form, ) -> impl Future<Output = Result<R, WechatError>> + Send
where R: DeserializeOwned, U: IntoUrl + Send, Self: Sync,

Source§

fn upload_with<R, U, T>( &self, url: U, data: &T, multipart: Form, ) -> impl Future<Output = Result<R, WechatError>> + Send
where R: DeserializeOwned, U: IntoUrl + Send, T: Serialize + Sync + ?Sized, Self: Sync,

Source§

fn json<R, U, T>( &self, url: U, data: &T, ) -> impl Future<Output = Result<R, WechatError>> + Send
where R: DeserializeOwned, U: IntoUrl + Send, T: Serialize + Sync + ?Sized, Self: Sync,

Source§

fn download<U, T>( &self, url: U, query: &T, ) -> impl Future<Output = Result<Vec<u8>, WechatError>> + Send
where U: IntoUrl + Send, T: Serialize + Sync + ?Sized, Self: Sync,

Source§

impl Clone for RobotClient

Source§

fn clone(&self) -> RobotClient

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,