Skip to main content

Crate wechat_profile

Crate wechat_profile 

Source
Expand description

Readers and narrow opt-in writers for selected official Linux profiles.

Offline readers use a private temporary copy, including its WAL, without changing source SHM. An owned daemon can instead reuse read-only connections while serializing profile operations. This crate neither launches WeChat nor connects to the network or acquires keys from a process. Checked write functions require explicit ownership and a durable caller intent.

§API guide

Start with ProfileReader for history, contacts, groups and local media. ReadOptions requires a stopped writer or a consistent copy. The library understands supported official file layouts; it supplies no account daemon, network requests or alternative settled-state database.

Advanced writers use the following naming conventions. These are names for this adapter’s operations, not official-client API names.

PrefixEffectExample
stage_*Prepare validated bytes in memory without changing filesstage_mmkv_values
apply_*Usually a logical update to supported profile recordsapply_message_projection
publish_*Usually installation of prepared bytes at local pathspublish_mmkv_append, publish_cache_file

Both apply_* and publish_* perform writes. Their names are descriptive, not separate transaction levels: publish_saved_key_info can change both a database and a file, and media apply operations can also install cache files. New profile mutations use apply_*; existing publish_* names are retained for compatibility. stage_* remains the convention for preparing a change without writing to the profile. “Prepared” means bytes already constructed and checked, such as the encrypted data and CRC metadata returned by stage_mmkv_values. It does not mean an additional profile or a network publication.

A SQLite transaction or an atomic file replacement does not make a change across several databases/files atomic. The caller owns exclusive access and recovery ordering. WriteOptions::durable_intent_id references a recovery record the caller has already saved; the crate neither creates that record nor proves its existence. Unrecognized layouts remain unsupported for writes.

Structs§

AppliedContact
AppliedContactPin
AppliedHardlink
AppliedHardlinkCache
AppliedImageCache
AppliedMediaResource
AppliedMessage
AppliedText
AppliedVoiceCache
AvatarProjection
Avatar hashes identify the native source URL, not the image-content digest. A caller supplies the observed URL hash explicitly; it is never inferred from the bytes. No contact/group field or remote avatar is modified.
BusinessContactProjection
CachedBytes
CachedImage
ColumnSchema
Contact
ContactProjection
Full scalar/BLOB contact data with id/username allocated from the destination name map. Existing rows accept patches; new rows require every remaining field.
Coverage
DatLayout
DatabaseInventory
DatabaseKey
DecodedField
Group
GroupMember
GroupMentionPermissions
Derived from the official room owner, administrator list and SQL membership. Missing profile evidence stays unknown; no separate permission state is saved.
GroupProjection
Caller supplies the actual retained group fields; complete_roster is explicit. No absent member is deleted for an incomplete/delta roster.
HardlinkProjection
Native hardlink fields, excluding rowid/dir1/dir2. Directory numbers are always allocated in the destination. hardlink_md5_hash computes the native string hash; type/extra_buffer remain explicit in this low-level interface.
ImageDatKey
IncomingText
IndexSchema
InitializedLayout
KeyFile
ListQuery
MediaResourceProjection
Exact native resource metadata. The destination allocates all local IDs and translates names. Detail type/status/data_index and opaque protobuf bytes are explicit build-adapter inputs rather than guessed media-wide defaults.
Message
MessageProjection
Exact stored columns supplied by a protocol/build adapter, excluding fields allocated/transformed by this destination (local_id, sender id, packed endpoints).
MessageQuery
MessageReference
Membership for a history view, without reading or decoding message bodies.
MessageSessionProjection
MmkvPublication
MmkvRecords
Decoded v4 records are secrets; Debug and serde intentionally unavailable.
NativeMemberPatch
NativeRosterPatch
OfficialHomeBootstrap
Credentials and additional raw MMKV values are caller supplied; this type has no Debug/Serialize so a bootstrap request cannot enter ordinary logs.
OfficialHomeReport
OwnedReaderCache
Page
PeerBusinessMetadata
PeerMetadata
PeerOpenImApplication
PeerOpenImMetadata
PeerOpenImWording
ProfileIdentity
ProfileLocation
ProfileReader
ProfileSavedLogin
Authorized saved material only; it does not imply a currently valid session. Values are zeroized and intentionally do not implement Debug or Serialize.
ReadOptions
ReadProjection
SavedKeyInfoPlan
Hash-only expected generations, suitable for embedding in a coordinator’s encrypted journal. No credential bytes are returned by this plan.
SavedKeyInfoPublication
SavedLoginProjection
One accepted credential generation. No Debug/serde implementation is provided. The caller binds this generation to bootstrap username/UIN/device first.
SchemaReport
SecretBytes
SourceMessageId
Local IDs are scoped to a database and a table. Decimal strings avoid a lossy JSON floating-point conversion and are not native server checkpoints.
StagedMmkv
Complete staged pair. Publication across these files requires caller recovery; this object alone never modifies any filesystem or native sync checkpoint.
TableSchema
Thread
ThreadExitReadProjection
ThreadReadProjection
WriteOptions

Enums§

DatabaseState
DecodeState
HardlinkKind
ImageQuality
KeyInfoSource
NativeGroupEdit
Effects established for ordinary Linux group controls. This writer never deletes chat history and never treats a membership delta as a full roster.
ProfileError
SqlValue
ThreadExitReadOutcome
VerifiedImageQuality
VideoQuality

Constants§

MAX_CACHED_FILE_BYTES
MAX_CACHED_MEDIA_BYTES
MAX_DAT_PLAINTEXT_BYTES

Functions§

account_contact_sync_store_path
The inspected contact drain stores its independent SyncKeyBuffer here. It does not use mmkv_key_byp_sync_key from the login store.
account_mmkv_key
The inspected per-account v2 store derives its CFB key from the account name, independently of global format keys, database passwords and login credentials. This is a format derivation, not a means of authenticating an account.
account_sync_store_path
Select the observed account login store only after exact username/UIN binding.
apply_avatar_projection
apply_contact_business_patch
Apply a received business contact and its ordinary extra metadata in one transaction. This performs no refresh or other account operation.
apply_contact_mute_patch
Apply only a received direct-contact mute bit. Missing or incomplete contact identities cannot establish the other flag bits and are left untouched.
apply_contact_patch
Sparse contact update. Existing rows preserve every omitted field. A new row starts with a zero deletion flag; other omitted nullable/no-default columns become SQL NULL. Explicit input values take precedence over these defaults.
apply_contact_pin_patch
Apply a received ordinary pin preference. The caller retains a stable transition timestamp and retries the same intent after a partial local write. Session and contact commits are separate; session-first publication lets a retry recognize an unfinished flag transition without rewinding newer activity.
apply_contact_projection
apply_group_patch
Sparse group updates use the same explicit SQL NULL policy for a new row. Existing owner/opaque buffers are preserved unless specifically supplied.
apply_group_projection
apply_hardlink_projection
apply_incoming_text
Supports only the verified existing direct-chat incoming text family. It does not allocate new chats/maps, infer sort collisions, update FTS or project unknown media/system commands. A partial error may follow a committed message transaction; recover by retrying the same durable input.
apply_media_resource_projection
apply_media_resource_variants
Add one or more verified resource variants without erasing other qualities. Only a matching pending (status0,size0) detail can transition to downloaded.
apply_message_projection
apply_message_session_projection
Reconcile a committed message into a desktop session, preserving drafts, unrelated unread rows and preexisting counter/list discrepancies. It makes no server/phone read request and is retryable after a message-only commit.
apply_native_group_edit
apply_native_roster_patch
Translate only the proved network member identity/display semantics into the local repeated-field1 representation. Caller proves roster completeness (for example, a separate complete member identity list in the server reply). Unknown root/member protobuf chunks, existing owner and unrelated contact fields are retained byte-for-byte. No network version is guessed into opaque fields.
apply_recall_projection
Replace the live row while preserving its source/server identity and ordering. Media cache files and unknown official files have independent lifetimes.
apply_recall_projection_with_notice
Preserve the server’s replacement text as XML text, never as markup.
apply_session_projection
Explicit session fields. New sessions require a complete row; patches retain unrelated drafts/read metadata. Caller determines actual native values.
cache_file_projection
Register an ordinary subtype6 attachment’s verified bytes, resource row, filename pair and native hardlink. A new collision-bounded local name is an explicit allocation policy; an existing resource filename is retained.
cache_hardlink_media_projection
Register verified ordinary file/video bytes in the observed month/hardlink namespace. This does not invent a MessageResourceDetail subtype or packed attachment record; adapters with that metadata can register it separately. A digest prefix makes the local filename deterministic and collision bounded.
cache_image_projection
Cache one actual JPEG/PNG quality under a deterministic local basename. The observed DAT/resource/hardlink representation is retained; basename allocation and UTC month are local policies, not a claim about the native generator. No other variant is removed. Original bytes must match the message XML MD5.
cache_video_projection
Cache one video representation using the resource basename plus its exact native suffix. Movie and JPEG thumbnail bytes are never interchanged, and adding one quality preserves every other resource detail and basename.
cache_voice_projection
Preserve the original encoded voice, independently of any WAV derivative. The supported media shard is selected only when no other media ordinal exists. The message row must already exist and be type 34 in its own table namespace.
choose_message_sort_sequence
Choose the first unused millisecond slot in this message’s second, or retain the already stored slot for a replay. This is an independent collision policy within the observed native 1000-slots/second representation, not a recovered native rollover algorithm. Caller holds the lease through insertion.
compressed_profile_field
WCDB compression state 4 observed on the supported fields. Compression is independent of media type; raw protocol bytes stay in the durable sidecar.
create_mmkv_v4
New nonexpiring v4 pair with explicit caller-generated key and IV. Fixed capacity is the total page-aligned data-file size, including its 4-byte reserved header. The metadata occupies one 4096-byte page, matching the inspected native files. Maximum data capacity is 4 MiB.
decode_dat_v2
Independent V2 framing decode. ECB/XOR is not authenticated encryption; callers must separately validate image format/dimensions before rendering.
decode_mmkv_records
derive_image_dat_key
encode_dat_v2
ensure_managed_layout_version
Repair only the omitted known v4 marker of this adapter’s receipt-bound managed bootstrap. The coordinator must establish that provenance first. No schema migration, UUID generation, stock-scan completion or foreign profile adoption is implied by this helper.
file_resource_type
Resource categories from the supported Linux build’s extension registry. An unknown extension uses its observed generic category; these are file resource types, independently of the file hardlink table’s constant type 1. Supported Linux 4.1.13.26 AMD64: registry 0x7554e70, classifier 0x7558600, resource constructors 0x755c1ca/0x755d66f (category << 16 | 3).
find_projected_message
Find one exact server identity in the sole supported ordinary shard. This never adopts a first match from an ambiguous or rotated shard family.
hardlink_md5_hash
Native 32-bit SuperFastHash of the 32 ASCII hex characters, not decoded MD5. SQLite stores its unsigned result as a nonnegative 64-bit INTEGER.
initialize_official_home
Minimal ordinary HOME and explicit identity, without saved credentials.
initialize_official_home_with_login
Fresh official-format HOME with server-issued saved credentials. Known global records and native legacy key-info fallback are initialized, without guessing a key_md5 value. Same-build official startup acceptance remains a runtime check.
initialize_profile
Creates a NEW account root atomically. The caller supplies an existing/new 32-byte binary database password explicitly and stores returned keys separately. For an official home this is the accepted account AuthSect field 9 payload; generating another password cannot substitute for that server-issued value. This initializes ordinary native schemas; it does not claim a fully trusted login profile or manufacture custom-tokenizer indexes.
keys_from_agent_cache
Read only the matching authorized cached key records from a coherent copied agent database. This never calls the old database initializer/migrator or any key acquisition process. The agent token is an unlock passphrase, not an exported profile key or network credential.
keys_from_password
Export only validated per-file keys from an explicitly supplied existing account password. No password discovery, fallback, account switch, or source mutation takes place; the password itself is not retained in the result.
mark_read_messages
Project only the selected source-qualified incoming observations. This is desktop-local state: it neither acknowledges consumer events nor sends a read receipt to the phone. Counter/list discrepancies already present are retained by subtracting only removed rows rather than rebuilding from list cardinality.
mark_read_thread
Clear this session through a frozen server timestamp, preserving later rows. Unlike an exact-ID projection, this reconciles an older counter/list mismatch when the entire known session is before the boundary. It performs no RPC.
mark_read_thread_exit
Project only the unread-clear component of a recognized session-exit control. Missing, hidden and excluded sessions remain unchanged. The caller must retain the full control as incomplete and journal every evaluated result.
mmkv_string_value
Native string/Data encoding used inside each MMKV value record.
official_account_directory
Observed directory naming in the inspected Linux profile. The suffix is the first four lowercase MD5 hex digits of decimal UIN, not a username hash. The complete fresh-home takeover still needs a same-build compatibility check.
parse_dat_v2
plan_saved_key_info
Inspect only caller-confirmed stopped files, copying DB/WAL/SHM before SQLite. Existing databases must have the exact known unique-index/table shape.
publish_cache_file
Create one content-verified cache file without replacing any existing path. The adapter supplies a native relative path, encoded bytes and expected SHA. Atomic publication is idempotent; SQL resource registration is a later step.
publish_legacy_key_info
Atomic legacy fallback publication with an expected old-generation SHA-256. None means a new file, never permission to overwrite unknown contents. The coordinator journals/retries this step under its exclusive profile lease.
publish_mmkv_append
Publish a previously staged append while the caller holds exclusive profile ownership and its durable intent. Data is replaced first: the old metadata still validates the unchanged ciphertext prefix. Metadata publication exposes the new span. Replay accepts the intermediate new-data/old-metadata state. This is not atomic with database, credential or sidecar cursor transactions.
publish_mmkv_append_guarded
Recheck an external authorization fence before each independent data/metadata commit. If the fence closes between commits, the caller retains its sealed intent and the ordinary append replay rules accept the data-first state.
publish_mmkv_create
Publish a journaled newly created pair without replacing any existing bytes. Replay accepts only exact staged files, including a data-only crash state. The caller must authorize the missing store (e.g. its managed bootstrap receipt) and create/own the canonical parent directory before calling this function.
publish_saved_key_info
Publish native-shaped key-info, retaining unrelated accounts/history. The inspected writer supplies key_md5=‘’ (not a digest of the new credential). Its known UNIQUE(user_name_md5,key_info_md5) tuple is replaced only when the older tuple contains identical bytes and the same native empty key_md5. If no DB exists, use the native raw legacy fallback without inventing a DB.
publish_saved_key_info_guarded
The coordinator must recheck its authorization fence immediately before each independently durable publication. A false guard preserves the caller’s encrypted intent for replay; it cannot roll back an earlier committed file.
read_account_sync_key
Read the desktop cursor from a caller-confirmed stopped/coherent account. The binary cursor is independent of saved-login and business-session keys.
read_mmkv_identity
CRC32 checks the captured ciphertext span; it is not authentication. Identity values must also match the independently authenticated native account.
read_profile_key_info
Restore only the existing account’s key-info for a new approval/QR exchange. This remains useful when saved AutoAuth trust is expired or unavailable; a fresh approval does not justify dropping the installation’s key-info.
read_profile_saved_login
Read identity and the exact native latest-row/legacy selection from a stopped full HOME. Database/WAL/SHM queries use an isolated working copy; encrypted profile DB keys and native login credentials are never substituted.
remove_recalled_search
Remove only the supported ordinary index entries for this exact owned source. The caller retains its recall intent and retries local work after interruption.
saved_login_policy
Preserve the existing desktop auto-login policy while reading a bound store.
stage_accepted_saved_login_projection
Accepted-login-only variant. The caller must have installed the matching authenticated generation and cleared its own logout fence first. Generic staging retains the logout flag; only this explicit path may clear it.
stage_account_contact_sync_key
stage_account_sync_key
Stage the native account store’s cursor. A coordinator must first durably apply every relevant command and journal this sealed generation before publication.
stage_mmkv_sync_key
Stage the proved native SyncKey string field in an explicitly selected account store. This does not guess the path, write the legacy file, or advance a cursor.
stage_mmkv_values
Append while preserving IV/sequence/flags and the complete old ciphertext prefix. A full data file grows to the next 4096-byte page, at most 4 MiB; records are never compacted or discarded. Identical values are byte-idempotent. Values are already MMKV-encoded; None is a tombstone. Unknown keys survive.
stage_saved_login_projection
Stage accepted saved credentials against an already bound identity store. No filesystem mutation occurs, so a coordinator can journal the complete sealed generation before publishing the MMKV pair and legacy key-info file.
verify_profile_password
Confirm a server-issued account database password against every actual DB header and the already authorized page-key map. Only 4096-byte headers are read; SQLite never opens these files, and no key/password bytes are returned. The caller must hold exclusive profile ownership or supply a stopped copy. Missing coverage, a different salt generation or one mismatched key fails closed. This does not rekey, repair, replace or switch the attached profile.

Type Aliases§

RawFields
Result