1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Connect to WeChat, authenticate, synchronize and submit messages with [`NativeClient`].
//!
//! Most server operations are **methods on [`NativeClient`]**, rather than free
//! functions in this crate's Functions list. [`AccountState`] holds accepted
//! credentials; it is secret, mutable state, not an API access token.
//!
//! | Task | Start here |
//! | --- | --- |
//! | QR login | [`NativeClient::start_qr_login`], [`NativeClient::poll_login`], [`NativeClient::complete_login`] |
//! | Receive a sync page | [`NativeClient::sync`], [`wire::decode_add_message`] |
//! | Send text | [`NativeClient::send_text`], [`TextSendResult`] |
//! | Contacts and rooms | [`NativeClient::lookup_contacts`], [`NativeClient::lookup_room`] |
//! | Attachments | [`media`], [`media_send`], [`NativeClient::send_file`] |
//! | Low-level encoding | [`wire`], [`protobuf`] |
//!
//! # Send one text message
//!
//! After an approved login, call the client method with the recipient's exact
//! WeChat username. Persist the task ID, timestamp and intended operation in your
//! application's recovery record before submission. A client ID is not a server
//! guarantee against duplicate sends.
//!
//! ```no_run
//! use wechat_protocol::{wire, AccountState, NativeClient, TextSendResult};
//!
//! fn send_once(
//! client: &NativeClient,
//! state: &mut AccountState,
//! recipient: &str,
//! text: &str,
//! task_id: &str,
//! created_at: u32,
//! ) -> anyhow::Result<TextSendResult> {
//! let client_id = wire::client_message_id(task_id.as_bytes());
//! anyhow::ensure!(client_id != 0, "Choose another task ID");
//! client.send_text(state, recipient, text, created_at, client_id)
//! }
//! ```
//!
//! The source package includes runnable `qr_login`, `send_text` and `sync_once`
//! examples. They keep credentials in memory and perform no profile writes.
//!
//! # Application responsibilities
//!
//! The crate implements supported wire operations, transport authentication and
//! response decoding. The embedding application owns credential storage, send
//! intents, uncertainty handling, sync recovery and official-profile writeback.
//! An accepted receipt establishes server acceptance, not recipient playback or
//! completed local history. An error after submission must not cause a blind resend.
//!
//! This library does not launch or load the official client. Peer responses pass
//! pinned MMTLS signature and record authentication before business decode.
//! Network methods block; async applications must use a blocking worker.
pub use login_lan_error_reason;
pub use *;
pub const MAX_MESSAGE_BYTES: usize = 16 * 1024 * 1024;