pub struct CdnClient { /* private fields */ }Expand description
HTTP client for WeChat CDN media endpoints.
Cheap to Clone — shares the underlying reqwest::Client, which uses
an Arc internally.
§Example
use wechat_ilink::{CdnClient, CDNMedia};
let cdn = CdnClient::new();
let bytes = cdn.download(&media, None).await?;Implementations§
Source§impl CdnClient
impl CdnClient
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a CdnClient with a fresh internal reqwest::Client.
Sourcepub fn with_client(http: Client) -> Self
pub fn with_client(http: Client) -> Self
Create a CdnClient that reuses an existing reqwest::Client.
Useful when the caller already maintains a shared HTTP client with custom proxy / TLS / timeout configuration.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the CDN base URL (defaults to CDN_BASE_URL).
Primarily intended for tests and regional endpoints.
Sourcepub async fn download(
&self,
media: &CDNMedia,
aes_key_override: Option<&str>,
) -> Result<Vec<u8>>
pub async fn download( &self, media: &CDNMedia, aes_key_override: Option<&str>, ) -> Result<Vec<u8>>
Download and AES-decrypt a CDN media object.
aes_key_override is used when the decryption key is attached to the
message metadata (e.g. ImageContent::aes_key)
rather than embedded in the media’s own aes_key field.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CdnClient
impl !RefUnwindSafe for CdnClient
impl Send for CdnClient
impl Sync for CdnClient
impl Unpin for CdnClient
impl UnsafeUnpin for CdnClient
impl !UnwindSafe for CdnClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more