Skip to main content

Crate wacore_derive

Crate wacore_derive 

Source
Expand description

Derive macros for wacore protocol types.

This crate provides derive macros for implementing the ProtocolNode trait on structs that represent WhatsApp protocol nodes.

§Example

use wacore_derive::{ProtocolNode, WireEnum};

/// A query request node.
/// Wire format: `<query request="interactive"/>`
#[derive(ProtocolNode)]
#[protocol(tag = "query")]
pub struct QueryRequest {
    #[attr(name = "request", default = "interactive")]
    pub request_type: String,
}

/// An enum with string representation.
#[derive(WireEnum)]
pub enum MemberAddMode {
    #[wire = "admin_add"]
    AdminAdd,
    #[wire = "all_member_add"]
    AllMemberAdd,
}

Derive Macros§

EmptyNode
Derive macro for empty protocol nodes (tag only, no attributes).
ProtocolNode
Derive macro for implementing ProtocolNode on structs with attributes.
WireEnum